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 strict_mode_flag() == kStrictMode; } | 55 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } |
56 StrictModeFlag strict_mode_flag() const { | 56 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } |
57 return StrictModeFlagField::decode(flags_); | 57 bool is_strict_or_extended_mode() const { return !is_classic_mode(); } |
rossberg
2011/11/08 15:02:46
Same here.
Steven
2011/11/08 16:13:49
Done.
| |
58 LanguageMode language_mode() const { | |
59 return LanguageModeField::decode(flags_); | |
58 } | 60 } |
59 bool is_in_loop() const { return IsInLoop::decode(flags_); } | 61 bool is_in_loop() const { return IsInLoop::decode(flags_); } |
60 FunctionLiteral* function() const { return function_; } | 62 FunctionLiteral* function() const { return function_; } |
61 Scope* scope() const { return scope_; } | 63 Scope* scope() const { return scope_; } |
62 Handle<Code> code() const { return code_; } | 64 Handle<Code> code() const { return code_; } |
63 Handle<JSFunction> closure() const { return closure_; } | 65 Handle<JSFunction> closure() const { return closure_; } |
64 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } | 66 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
65 Handle<Script> script() const { return script_; } | 67 Handle<Script> script() const { return script_; } |
66 v8::Extension* extension() const { return extension_; } | 68 v8::Extension* extension() const { return extension_; } |
67 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } | 69 ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
68 Handle<Context> calling_context() const { return calling_context_; } | 70 Handle<Context> calling_context() const { return calling_context_; } |
69 int osr_ast_id() const { return osr_ast_id_; } | 71 int osr_ast_id() const { return osr_ast_id_; } |
70 | 72 |
71 void MarkAsEval() { | 73 void MarkAsEval() { |
72 ASSERT(!is_lazy()); | 74 ASSERT(!is_lazy()); |
73 flags_ |= IsEval::encode(true); | 75 flags_ |= IsEval::encode(true); |
74 } | 76 } |
75 void MarkAsGlobal() { | 77 void MarkAsGlobal() { |
76 ASSERT(!is_lazy()); | 78 ASSERT(!is_lazy()); |
77 flags_ |= IsGlobal::encode(true); | 79 flags_ |= IsGlobal::encode(true); |
78 } | 80 } |
79 void SetStrictModeFlag(StrictModeFlag strict_mode_flag) { | 81 void SetLanguageMode(LanguageMode language_mode) { |
80 ASSERT(StrictModeFlagField::decode(flags_) == kNonStrictMode || | 82 ASSERT(this->language_mode() != STRICT_MODE || |
81 StrictModeFlagField::decode(flags_) == strict_mode_flag); | 83 language_mode == STRICT_MODE || |
82 flags_ = StrictModeFlagField::update(flags_, strict_mode_flag); | 84 language_mode == EXTENDED_MODE); |
85 ASSERT(this->language_mode() != EXTENDED_MODE || | |
86 language_mode == EXTENDED_MODE); | |
rossberg
2011/11/08 15:02:46
All this asserts is this->language_mode() <= langu
Steven
2011/11/08 16:13:49
Done.
| |
87 flags_ = LanguageModeField::update(flags_, language_mode); | |
83 } | 88 } |
84 void MarkAsInLoop() { | 89 void MarkAsInLoop() { |
85 ASSERT(is_lazy()); | 90 ASSERT(is_lazy()); |
86 flags_ |= IsInLoop::encode(true); | 91 flags_ |= IsInLoop::encode(true); |
87 } | 92 } |
88 void MarkAsNative() { | 93 void MarkAsNative() { |
89 flags_ |= IsNative::encode(true); | 94 flags_ |= IsNative::encode(true); |
90 } | 95 } |
91 bool is_native() const { | 96 bool is_native() const { |
92 return IsNative::decode(flags_); | 97 return IsNative::decode(flags_); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 | 187 |
183 CompilationInfo() : function_(NULL) {} | 188 CompilationInfo() : function_(NULL) {} |
184 | 189 |
185 void Initialize(Mode mode) { | 190 void Initialize(Mode mode) { |
186 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | 191 mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
187 ASSERT(!script_.is_null()); | 192 ASSERT(!script_.is_null()); |
188 if (script_->type()->value() == Script::TYPE_NATIVE) { | 193 if (script_->type()->value() == Script::TYPE_NATIVE) { |
189 MarkAsNative(); | 194 MarkAsNative(); |
190 } | 195 } |
191 if (!shared_info_.is_null()) { | 196 if (!shared_info_.is_null()) { |
192 ASSERT(strict_mode_flag() == kNonStrictMode); | 197 ASSERT(language_mode() == CLASSIC_MODE); |
193 SetStrictModeFlag(shared_info_->strict_mode_flag()); | 198 SetLanguageMode(shared_info_->language_mode()); |
194 } | 199 } |
195 } | 200 } |
196 | 201 |
197 void SetMode(Mode mode) { | 202 void SetMode(Mode mode) { |
198 ASSERT(V8::UseCrankshaft()); | 203 ASSERT(V8::UseCrankshaft()); |
199 mode_ = mode; | 204 mode_ = mode; |
200 } | 205 } |
201 | 206 |
202 // Flags using template class BitField<type, start, length>. All are | 207 // Flags using template class BitField<type, start, length>. All are |
203 // false by default. | 208 // false by default. |
204 // | 209 // |
205 // Compilation is either eager or lazy. | 210 // Compilation is either eager or lazy. |
206 class IsLazy: public BitField<bool, 0, 1> {}; | 211 class IsLazy: public BitField<bool, 0, 1> {}; |
207 // Flags that can be set for eager compilation. | 212 // Flags that can be set for eager compilation. |
208 class IsEval: public BitField<bool, 1, 1> {}; | 213 class IsEval: public BitField<bool, 1, 1> {}; |
209 class IsGlobal: public BitField<bool, 2, 1> {}; | 214 class IsGlobal: public BitField<bool, 2, 1> {}; |
210 // Flags that can be set for lazy compilation. | 215 // Flags that can be set for lazy compilation. |
211 class IsInLoop: public BitField<bool, 3, 1> {}; | 216 class IsInLoop: public BitField<bool, 3, 1> {}; |
212 // Strict mode - used in eager compilation. | 217 // Strict mode - used in eager compilation. |
213 class StrictModeFlagField: public BitField<StrictModeFlag, 4, 1> {}; | 218 class LanguageModeField: public BitField<LanguageMode, 4, 2> {}; |
214 // Is this a function from our natives. | 219 // Is this a function from our natives. |
215 class IsNative: public BitField<bool, 6, 1> {}; | 220 class IsNative: public BitField<bool, 6, 1> {}; |
216 // Is this code being compiled with support for deoptimization.. | 221 // Is this code being compiled with support for deoptimization.. |
217 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; | 222 class SupportsDeoptimization: public BitField<bool, 7, 1> {}; |
218 // If compiling for debugging produce just full code matching the | 223 // If compiling for debugging produce just full code matching the |
219 // initial mode setting. | 224 // initial mode setting. |
220 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; | 225 class IsCompilingForDebugging: public BitField<bool, 8, 1> {}; |
221 | 226 |
222 | 227 |
223 unsigned flags_; | 228 unsigned flags_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 int column_offset, | 287 int column_offset, |
283 v8::Extension* extension, | 288 v8::Extension* extension, |
284 ScriptDataImpl* pre_data, | 289 ScriptDataImpl* pre_data, |
285 Handle<Object> script_data, | 290 Handle<Object> script_data, |
286 NativesFlag is_natives_code); | 291 NativesFlag is_natives_code); |
287 | 292 |
288 // Compile a String source within a context for Eval. | 293 // Compile a String source within a context for Eval. |
289 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, | 294 static Handle<SharedFunctionInfo> CompileEval(Handle<String> source, |
290 Handle<Context> context, | 295 Handle<Context> context, |
291 bool is_global, | 296 bool is_global, |
292 StrictModeFlag strict_mode); | 297 LanguageMode language_mode); |
293 | 298 |
294 // Compile from function info (used for lazy compilation). Returns true on | 299 // Compile from function info (used for lazy compilation). Returns true on |
295 // success and false if the compilation resulted in a stack overflow. | 300 // success and false if the compilation resulted in a stack overflow. |
296 static bool CompileLazy(CompilationInfo* info); | 301 static bool CompileLazy(CompilationInfo* info); |
297 | 302 |
298 // Compile a shared function info object (the function is possibly lazily | 303 // Compile a shared function info object (the function is possibly lazily |
299 // compiled). | 304 // compiled). |
300 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, | 305 static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node, |
301 Handle<Script> script); | 306 Handle<Script> script); |
302 | 307 |
303 // Set the function info for a newly compiled function. | 308 // Set the function info for a newly compiled function. |
304 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, | 309 static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
305 FunctionLiteral* lit, | 310 FunctionLiteral* lit, |
306 bool is_toplevel, | 311 bool is_toplevel, |
307 Handle<Script> script); | 312 Handle<Script> script); |
308 | 313 |
309 #ifdef ENABLE_DEBUGGER_SUPPORT | 314 #ifdef ENABLE_DEBUGGER_SUPPORT |
310 static bool MakeCodeForLiveEdit(CompilationInfo* info); | 315 static bool MakeCodeForLiveEdit(CompilationInfo* info); |
311 #endif | 316 #endif |
312 | 317 |
313 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 318 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
314 CompilationInfo* info, | 319 CompilationInfo* info, |
315 Handle<SharedFunctionInfo> shared); | 320 Handle<SharedFunctionInfo> shared); |
316 }; | 321 }; |
317 | 322 |
318 | 323 |
319 } } // namespace v8::internal | 324 } } // namespace v8::internal |
320 | 325 |
321 #endif // V8_COMPILER_H_ | 326 #endif // V8_COMPILER_H_ |
OLD | NEW |