| Index: src/compiler.h
|
| diff --git a/src/compiler.h b/src/compiler.h
|
| index be7361e9027b63117a1a7fdd2881fbf7519ef999..2194bfed7a5432049e873caedb6cbb043430bcc3 100644
|
| --- a/src/compiler.h
|
| +++ b/src/compiler.h
|
| @@ -57,11 +57,31 @@ class ScriptData {
|
| DISALLOW_COPY_AND_ASSIGN(ScriptData);
|
| };
|
|
|
| -
|
| // CompilationInfo encapsulates some information known at compile time. It
|
| // is constructed based on the resources available at compile-time.
|
| class CompilationInfo {
|
| public:
|
| + // Various configuration flags for a compilation, as well as some properties
|
| + // of the compiled code produced by a compilation.
|
| + enum Flag {
|
| + kLazy = 1 << 0,
|
| + kEval = 1 << 1,
|
| + kGlobal = 1 << 2,
|
| + kStrictMode = 1 << 3,
|
| + kThisHasUses = 1 << 4,
|
| + kNative = 1 << 5,
|
| + kDeferredCalling = 1 << 6,
|
| + kNonDeferredCalling = 1 << 7,
|
| + kSavesCallerDoubles = 1 << 8,
|
| + kRequiresFrame = 1 << 9,
|
| + kMustNotHaveEagerFrame = 1 << 10,
|
| + kDeoptimizationSupport = 1 << 11,
|
| + kDebug = 1 << 12,
|
| + kCompilingForDebugging = 1 << 13,
|
| + kParseRestriction = 1 << 14,
|
| + kSerializing = 1 << 15
|
| + };
|
| +
|
| CompilationInfo(Handle<JSFunction> closure, Zone* zone);
|
| CompilationInfo(Isolate* isolate, Zone* zone);
|
| virtual ~CompilationInfo();
|
| @@ -71,10 +91,12 @@ class CompilationInfo {
|
| }
|
| Zone* zone() { return zone_; }
|
| bool is_osr() const { return !osr_ast_id_.IsNone(); }
|
| - bool is_lazy() const { return IsLazy::decode(flags_); }
|
| - bool is_eval() const { return IsEval::decode(flags_); }
|
| - bool is_global() const { return IsGlobal::decode(flags_); }
|
| - StrictMode strict_mode() const { return StrictModeField::decode(flags_); }
|
| + bool is_lazy() const { return GetFlag(kLazy); }
|
| + bool is_eval() const { return GetFlag(kEval); }
|
| + bool is_global() const { return GetFlag(kGlobal); }
|
| + StrictMode strict_mode() const {
|
| + return GetFlag(kStrictMode) ? STRICT : SLOPPY;
|
| + }
|
| FunctionLiteral* function() const { return function_; }
|
| Scope* scope() const { return scope_; }
|
| Scope* global_scope() const { return global_scope_; }
|
| @@ -98,12 +120,12 @@ class CompilationInfo {
|
|
|
| void MarkAsEval() {
|
| DCHECK(!is_lazy());
|
| - flags_ |= IsEval::encode(true);
|
| + SetFlag(kEval);
|
| }
|
|
|
| void MarkAsGlobal() {
|
| DCHECK(!is_lazy());
|
| - flags_ |= IsGlobal::encode(true);
|
| + SetFlag(kGlobal);
|
| }
|
|
|
| void set_parameter_count(int parameter_count) {
|
| @@ -112,83 +134,52 @@ class CompilationInfo {
|
| }
|
|
|
| void set_this_has_uses(bool has_no_uses) {
|
| - this_has_uses_ = has_no_uses;
|
| + SetFlag(kThisHasUses, has_no_uses);
|
| }
|
|
|
| - bool this_has_uses() {
|
| - return this_has_uses_;
|
| - }
|
| + bool this_has_uses() { return GetFlag(kThisHasUses); }
|
|
|
| void SetStrictMode(StrictMode strict_mode) {
|
| - DCHECK(this->strict_mode() == SLOPPY || this->strict_mode() == strict_mode);
|
| - flags_ = StrictModeField::update(flags_, strict_mode);
|
| + SetFlag(kStrictMode, strict_mode == STRICT);
|
| }
|
|
|
| - void MarkAsNative() {
|
| - flags_ |= IsNative::encode(true);
|
| - }
|
| + void MarkAsNative() { SetFlag(kNative); }
|
|
|
| - bool is_native() const {
|
| - return IsNative::decode(flags_);
|
| - }
|
| + bool is_native() const { return GetFlag(kNative); }
|
|
|
| bool is_calling() const {
|
| - return is_deferred_calling() || is_non_deferred_calling();
|
| + return GetFlag(kDeferredCalling) || GetFlag(kNonDeferredCalling);
|
| }
|
|
|
| - void MarkAsDeferredCalling() {
|
| - flags_ |= IsDeferredCalling::encode(true);
|
| - }
|
| + void MarkAsDeferredCalling() { SetFlag(kDeferredCalling); }
|
|
|
| - bool is_deferred_calling() const {
|
| - return IsDeferredCalling::decode(flags_);
|
| - }
|
| + bool is_deferred_calling() const { return GetFlag(kDeferredCalling); }
|
|
|
| - void MarkAsNonDeferredCalling() {
|
| - flags_ |= IsNonDeferredCalling::encode(true);
|
| - }
|
| + void MarkAsNonDeferredCalling() { SetFlag(kNonDeferredCalling); }
|
|
|
| - bool is_non_deferred_calling() const {
|
| - return IsNonDeferredCalling::decode(flags_);
|
| - }
|
| + bool is_non_deferred_calling() const { return GetFlag(kNonDeferredCalling); }
|
|
|
| - void MarkAsSavesCallerDoubles() {
|
| - flags_ |= SavesCallerDoubles::encode(true);
|
| - }
|
| + void MarkAsSavesCallerDoubles() { SetFlag(kSavesCallerDoubles); }
|
|
|
| - bool saves_caller_doubles() const {
|
| - return SavesCallerDoubles::decode(flags_);
|
| - }
|
| + bool saves_caller_doubles() const { return GetFlag(kSavesCallerDoubles); }
|
|
|
| - void MarkAsRequiresFrame() {
|
| - flags_ |= RequiresFrame::encode(true);
|
| - }
|
| + void MarkAsRequiresFrame() { SetFlag(kRequiresFrame); }
|
|
|
| - bool requires_frame() const {
|
| - return RequiresFrame::decode(flags_);
|
| - }
|
| + bool requires_frame() const { return GetFlag(kRequiresFrame); }
|
|
|
| - void MarkMustNotHaveEagerFrame() {
|
| - flags_ |= MustNotHaveEagerFrame::encode(true);
|
| - }
|
| + void MarkMustNotHaveEagerFrame() { SetFlag(kMustNotHaveEagerFrame); }
|
|
|
| bool GetMustNotHaveEagerFrame() const {
|
| - return MustNotHaveEagerFrame::decode(flags_);
|
| + return GetFlag(kMustNotHaveEagerFrame);
|
| }
|
|
|
| - void MarkAsDebug() {
|
| - flags_ |= IsDebug::encode(true);
|
| - }
|
| + void MarkAsDebug() { SetFlag(kDebug); }
|
|
|
| - bool is_debug() const {
|
| - return IsDebug::decode(flags_);
|
| - }
|
| + bool is_debug() const { return GetFlag(kDebug); }
|
|
|
| - void PrepareForSerializing() {
|
| - flags_ |= PrepareForSerializing::encode(true);
|
| - }
|
| + void PrepareForSerializing() { SetFlag(kSerializing); }
|
|
|
| - bool will_serialize() const { return PrepareForSerializing::decode(flags_); }
|
| + bool will_serialize() const { return GetFlag(kSerializing); }
|
|
|
| bool IsCodePreAgingActive() const {
|
| return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
|
| @@ -196,11 +187,12 @@ class CompilationInfo {
|
| }
|
|
|
| void SetParseRestriction(ParseRestriction restriction) {
|
| - flags_ = ParseRestricitonField::update(flags_, restriction);
|
| + SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION);
|
| }
|
|
|
| ParseRestriction parse_restriction() const {
|
| - return ParseRestricitonField::decode(flags_);
|
| + return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL
|
| + : NO_PARSE_RESTRICTION;
|
| }
|
|
|
| void SetFunction(FunctionLiteral* literal) {
|
| @@ -234,12 +226,8 @@ class CompilationInfo {
|
| context_ = context;
|
| }
|
|
|
| - void MarkCompilingForDebugging() {
|
| - flags_ |= IsCompilingForDebugging::encode(true);
|
| - }
|
| - bool IsCompilingForDebugging() {
|
| - return IsCompilingForDebugging::decode(flags_);
|
| - }
|
| + void MarkCompilingForDebugging() { SetFlag(kCompilingForDebugging); }
|
| + bool IsCompilingForDebugging() { return GetFlag(kCompilingForDebugging); }
|
| void MarkNonOptimizable() {
|
| SetMode(CompilationInfo::NONOPT);
|
| }
|
| @@ -273,11 +261,11 @@ class CompilationInfo {
|
|
|
| // Deoptimization support.
|
| bool HasDeoptimizationSupport() const {
|
| - return SupportsDeoptimization::decode(flags_);
|
| + return GetFlag(kDeoptimizationSupport);
|
| }
|
| void EnableDeoptimizationSupport() {
|
| DCHECK(IsOptimizable());
|
| - flags_ |= SupportsDeoptimization::encode(true);
|
| + SetFlag(kDeoptimizationSupport);
|
| }
|
|
|
| // Determines whether or not to insert a self-optimization header.
|
| @@ -397,41 +385,13 @@ class CompilationInfo {
|
| mode_ = mode;
|
| }
|
|
|
| - // Flags using template class BitField<type, start, length>. All are
|
| - // false by default.
|
| - //
|
| - // Compilation is either eager or lazy.
|
| - class IsLazy: public BitField<bool, 0, 1> {};
|
| - // Flags that can be set for eager compilation.
|
| - class IsEval: public BitField<bool, 1, 1> {};
|
| - class IsGlobal: public BitField<bool, 2, 1> {};
|
| - // If the function is being compiled for the debugger.
|
| - class IsDebug: public BitField<bool, 3, 1> {};
|
| - // Strict mode - used in eager compilation.
|
| - class StrictModeField: public BitField<StrictMode, 4, 1> {};
|
| - // Is this a function from our natives.
|
| - class IsNative: public BitField<bool, 5, 1> {};
|
| - // Is this code being compiled with support for deoptimization..
|
| - class SupportsDeoptimization: public BitField<bool, 6, 1> {};
|
| - // If compiling for debugging produce just full code matching the
|
| - // initial mode setting.
|
| - class IsCompilingForDebugging: public BitField<bool, 7, 1> {};
|
| - // If the compiled code contains calls that require building a frame
|
| - class IsCalling: public BitField<bool, 8, 1> {};
|
| - // If the compiled code contains calls that require building a frame
|
| - class IsDeferredCalling: public BitField<bool, 9, 1> {};
|
| - // If the compiled code contains calls that require building a frame
|
| - class IsNonDeferredCalling: public BitField<bool, 10, 1> {};
|
| - // If the compiled code saves double caller registers that it clobbers.
|
| - class SavesCallerDoubles: public BitField<bool, 11, 1> {};
|
| - // If the set of valid statements is restricted.
|
| - class ParseRestricitonField: public BitField<ParseRestriction, 12, 1> {};
|
| - // If the function requires a frame (for unspecified reasons)
|
| - class RequiresFrame: public BitField<bool, 13, 1> {};
|
| - // If the function cannot build a frame (for unspecified reasons)
|
| - class MustNotHaveEagerFrame: public BitField<bool, 14, 1> {};
|
| - // If we plan to serialize the compiled code.
|
| - class PrepareForSerializing : public BitField<bool, 15, 1> {};
|
| + void SetFlag(Flag flag) { flags_ |= flag; }
|
| +
|
| + void SetFlag(Flag flag, bool value) {
|
| + flags_ = value ? flags_ | flag : flags_ & ~flag;
|
| + }
|
| +
|
| + bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
|
|
|
| unsigned flags_;
|
|
|
| @@ -505,8 +465,6 @@ class CompilationInfo {
|
| // Number of parameters used for compilation of stubs that require arguments.
|
| int parameter_count_;
|
|
|
| - bool this_has_uses_;
|
| -
|
| Handle<Foreign> object_wrapper_;
|
|
|
| int optimization_id_;
|
|
|