summaryrefslogtreecommitdiffstats
path: root/src/compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.h')
-rw-r--r--src/compiler.h65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/compiler.h b/src/compiler.h
index 20868e54..1176c694 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -59,6 +59,7 @@ class CompilationInfo BASE_EMBEDDED {
v8::Extension* extension() const { return extension_; }
ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; }
Handle<Context> calling_context() const { return calling_context_; }
+ int osr_ast_id() const { return osr_ast_id_; }
void MarkAsEval() {
ASSERT(!is_lazy());
@@ -93,8 +94,66 @@ class CompilationInfo BASE_EMBEDDED {
ASSERT(is_eval());
calling_context_ = context;
}
+ void SetOsrAstId(int osr_ast_id) {
+ ASSERT(IsOptimizing());
+ osr_ast_id_ = osr_ast_id;
+ }
+
+ bool has_global_object() const {
+ return !closure().is_null() && (closure()->context()->global() != NULL);
+ }
+
+ GlobalObject* global_object() const {
+ return has_global_object() ? closure()->context()->global() : NULL;
+ }
+
+ // Accessors for the different compilation modes.
+ bool IsOptimizing() const { return mode_ == OPTIMIZE; }
+ bool IsOptimizable() const { return mode_ == BASE; }
+ void SetOptimizing(int osr_ast_id) {
+ SetMode(OPTIMIZE);
+ osr_ast_id_ = osr_ast_id;
+ }
+ void DisableOptimization() { SetMode(NONOPT); }
+
+ // Deoptimization support.
+ bool HasDeoptimizationSupport() const { return supports_deoptimization_; }
+ void EnableDeoptimizationSupport() {
+ ASSERT(IsOptimizable());
+ supports_deoptimization_ = true;
+ }
+
+ // Determine whether or not we can adaptively optimize.
+ bool AllowOptimize() {
+ return V8::UseCrankshaft() &&
+ !closure_.is_null() &&
+ function_->AllowOptimize();
+ }
private:
+ // Compilation mode.
+ // BASE is generated by the full codegen, optionally prepared for bailouts.
+ // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
+ // NONOPT is generated by the full codegen or the classic backend
+ // and is not prepared for recompilation/bailouts. These functions
+ // are never recompiled.
+ enum Mode {
+ BASE,
+ OPTIMIZE,
+ NONOPT
+ };
+
+ CompilationInfo() : function_(NULL) {}
+
+ void Initialize(Mode mode) {
+ mode_ = V8::UseCrankshaft() ? mode : NONOPT;
+ }
+
+ void SetMode(Mode mode) {
+ ASSERT(V8::UseCrankshaft());
+ mode_ = mode;
+ }
+
// Flags using template class BitField<type, start, length>. All are
// false by default.
//
@@ -130,6 +189,11 @@ class CompilationInfo BASE_EMBEDDED {
// handle otherwise.
Handle<Context> calling_context_;
+ // Compilation mode flag and whether deoptimization is allowed.
+ Mode mode_;
+ bool supports_deoptimization_;
+ int osr_ast_id_;
+
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
};
@@ -185,7 +249,6 @@ class Compiler : public AllStatic {
static bool MakeCodeForLiveEdit(CompilationInfo* info);
#endif
- private:
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
Handle<String> name,
int start_position,