OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); | 45 explicit CompilationInfo(Handle<SharedFunctionInfo> shared_info); |
46 explicit CompilationInfo(Handle<JSFunction> closure); | 46 explicit CompilationInfo(Handle<JSFunction> closure); |
47 | 47 |
48 Isolate* isolate() { | 48 Isolate* isolate() { |
49 ASSERT(Isolate::Current() == isolate_); | 49 ASSERT(Isolate::Current() == isolate_); |
50 return isolate_; | 50 return isolate_; |
51 } | 51 } |
52 bool is_lazy() const { return IsLazy::decode(flags_); } | 52 bool is_lazy() const { return IsLazy::decode(flags_); } |
53 bool is_eval() const { return IsEval::decode(flags_); } | 53 bool is_eval() const { return IsEval::decode(flags_); } |
54 bool is_global() const { return IsGlobal::decode(flags_); } | 54 bool is_global() const { return IsGlobal::decode(flags_); } |
55 bool is_strict_mode() const { return IsStrictMode::decode(flags_); } | 55 bool is_strict_mode() const { return strict_mode_flag() == kStrictMode; } |
| 56 StrictModeFlag strict_mode_flag() const { |
| 57 return StrictModeFlagField::decode(flags_); |
| 58 } |
56 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 59 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
57 FunctionLiteral* function() const { return function_; } | 60 FunctionLiteral* function() const { return function_; } |
58 Scope* scope() const { return scope_; } | 61 Scope* scope() const { return scope_; } |
59 Handle<Code> code() const { return code_; } | 62 Handle<Code> code() const { return code_; } |
60 Handle<JSFunction> closure() const { return closure_; } | 63 Handle<JSFunction> closure() const { return closure_; } |
61 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 64 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
62 Handle<Script> script() const { return script_; } | 65 Handle<Script> script() const { return script_; } |
63 v8::Extension* extension() const { return extension_; } | 66 v8::Extension* extension() const { return extension_; } |
64 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 67 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
65 Handle<Context> calling_context() const { return calling_context_; } | 68 Handle<Context> calling_context() const { return calling_context_; } |
66 int osr_ast_id() const { return osr_ast_id_; } | 69 int osr_ast_id() const { return osr_ast_id_; } |
67 | 70 |
68 void MarkAsEval() { | 71 void MarkAsEval() { |
69 ASSERT(!is_lazy()); | 72 ASSERT(!is_lazy()); |
70 flags_ |= IsEval::encode(true); | 73 flags_ |= IsEval::encode(true); |
71 } | 74 } |
72 void MarkAsGlobal() { | 75 void MarkAsGlobal() { |
73 ASSERT(!is_lazy()); | 76 ASSERT(!is_lazy()); |
74 flags_ |= IsGlobal::encode(true); | 77 flags_ |= IsGlobal::encode(true); |
75 } | 78 } |
76 void MarkAsStrictMode() { | 79 void SetStrictModeFlag(StrictModeFlag strict_mode_flag) { |
77 flags_ |= IsStrictMode::encode(true); | 80 flags_ = StrictModeFlagField::update(flags_, strict_mode_flag); |
78 } | |
79 StrictModeFlag StrictMode() { | |
80 return is_strict_mode() ? kStrictMode : kNonStrictMode; | |
81 } | 81 } |
82 void MarkAsInLoop() { | 82 void MarkAsInLoop() { |
83 ASSERT(is_lazy()); | 83 ASSERT(is_lazy()); |
84 flags_ |= IsInLoop::encode(true); | 84 flags_ |= IsInLoop::encode(true); |
85 } | 85 } |
86 void MarkAsNative() { | 86 void MarkAsNative() { |
87 flags_ |= IsNative::encode(true); | 87 flags_ |= IsNative::encode(true); |
88 } | 88 } |
89 bool is_native() const { | 89 bool is_native() const { |
90 return IsNative::decode(flags_); | 90 return IsNative::decode(flags_); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 }; | 179 }; |
180 | 180 |
181 CompilationInfo() : function_(NULL) {} | 181 CompilationInfo() : function_(NULL) {} |
182 | 182 |
183 void Initialize(Mode mode) { | 183 void Initialize(Mode mode) { |
184 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 184 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
185 ASSERT(!script_.is_null()); | 185 ASSERT(!script_.is_null()); |
186 if (script_->type()->value() == Script::TYPE_NATIVE) { | 186 if (script_->type()->value() == Script::TYPE_NATIVE) { |
187 MarkAsNative(); | 187 MarkAsNative(); |
188 } | 188 } |
189 if (!shared_info_.is_null() && shared_info_->strict_mode()) { | 189 if (!shared_info_.is_null()) { |
190 MarkAsStrictMode(); | 190 SetStrictModeFlag(shared_info_->strict_mode_flag()); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 void SetMode(Mode mode) { | 194 void SetMode(Mode mode) { |
195 ASSERT(V8::UseCrankshaft()); | 195 ASSERT(V8::UseCrankshaft()); |
196 mode_ = mode; | 196 mode_ = mode; |
197 } | 197 } |
198 | 198 |
199 // Flags using template class BitField<type, start, length>. All are | 199 // Flags using template class BitField<type, start, length>. All are |
200 // false by default. | 200 // false by default. |
201 // | 201 // |
202 // Compilation is either eager or lazy. | 202 // Compilation is either eager or lazy. |
203 class IsLazy: public BitField<bool, 0, 1> {}; | 203 class IsLazy: public BitField<bool, 0, 1> {}; |
204 // Flags that can be set for eager compilation. | 204 // Flags that can be set for eager compilation. |
205 class IsEval: public BitField<bool, 1, 1> {}; | 205 class IsEval: public BitField<bool, 1, 1> {}; |
206 class IsGlobal: public BitField<bool, 2, 1> {}; | 206 class IsGlobal: public BitField<bool, 2, 1> {}; |
207 // Flags that can be set for lazy compilation. | 207 // Flags that can be set for lazy compilation. |
208 class IsInLoop: public BitField<bool, 3, 1> {}; | 208 class IsInLoop: public BitField<bool, 3, 1> {}; |
209 // Strict mode - used in eager compilation. | 209 // Strict mode - used in eager compilation. |
210 class IsStrictMode: public BitField<bool, 4, 1> {}; | 210 class StrictModeFlagField: public BitField<StrictModeFlag, 4, 1> {}; |
211 // Is this a function from our natives. | 211 // Is this a function from our natives. |
212 class IsNative: public BitField<bool, 6, 1> {}; | 212 class IsNative: public BitField<bool, 6, 1> {}; |
213 // Is this code being compiled with support for deoptimization.. | 213 // Is this code being compiled with support for deoptimization.. |
214 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | 214 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; |
215 // If compiling for debugging produce just full code matching the | 215 // If compiling for debugging produce just full code matching the |
216 // initial mode setting. | 216 // initial mode setting. |
217 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | 217 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; |
218 | 218 |
219 | 219 |
220 unsigned flags_; | 220 unsigned flags_; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 309 |
310 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 310 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
311 CompilationInfo* info, | 311 CompilationInfo* info, |
312 Handle<SharedFunctionInfo> shared); | 312 Handle<SharedFunctionInfo> shared); |
313 }; | 313 }; |
314 | 314 |
315 | 315 |
316 } } // namespace v8::internal | 316 } } // namespace v8::internal |
317 | 317 |
318 #endif // V8_COMPILER_H_ | 318 #endif // V8_COMPILER_H_ |
OLD | NEW |