OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 17 matching lines...) Expand all Loading... |
28 #ifndef V8_COMPILER_H_ | 28 #ifndef V8_COMPILER_H_ |
29 #define V8_COMPILER_H_ | 29 #define V8_COMPILER_H_ |
30 | 30 |
31 #include "allocation.h" | 31 #include "allocation.h" |
32 #include "ast.h" | 32 #include "ast.h" |
33 #include "zone.h" | 33 #include "zone.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
| 38 static const int kPrologueOffsetNotSet = -1; |
| 39 |
38 class ScriptDataImpl; | 40 class ScriptDataImpl; |
39 | 41 |
40 // CompilationInfo encapsulates some information known at compile time. It | 42 // CompilationInfo encapsulates some information known at compile time. It |
41 // is constructed based on the resources available at compile-time. | 43 // is constructed based on the resources available at compile-time. |
42 class CompilationInfo { | 44 class CompilationInfo { |
43 public: | 45 public: |
44 CompilationInfo(Handle<Script> script, Zone* zone); | 46 CompilationInfo(Handle<Script> script, Zone* zone); |
45 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); | 47 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); |
46 CompilationInfo(Handle<JSFunction> closure, Zone* zone); | 48 CompilationInfo(Handle<JSFunction> closure, Zone* zone); |
47 | 49 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void SaveHandles() { | 181 void SaveHandles() { |
180 SaveHandle(&closure_); | 182 SaveHandle(&closure_); |
181 SaveHandle(&shared_info_); | 183 SaveHandle(&shared_info_); |
182 SaveHandle(&context_); | 184 SaveHandle(&context_); |
183 SaveHandle(&script_); | 185 SaveHandle(&script_); |
184 } | 186 } |
185 | 187 |
186 const char* bailout_reason() const { return bailout_reason_; } | 188 const char* bailout_reason() const { return bailout_reason_; } |
187 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; } | 189 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; } |
188 | 190 |
| 191 int prologue_offset() const { |
| 192 ASSERT_NE(kPrologueOffsetNotSet, prologue_offset_); |
| 193 return prologue_offset_; |
| 194 } |
| 195 |
| 196 void set_prologue_offset(int prologue_offset) { |
| 197 ASSERT_EQ(kPrologueOffsetNotSet, prologue_offset_); |
| 198 prologue_offset_ = prologue_offset; |
| 199 } |
| 200 |
189 private: | 201 private: |
190 Isolate* isolate_; | 202 Isolate* isolate_; |
191 | 203 |
192 // Compilation mode. | 204 // Compilation mode. |
193 // BASE is generated by the full codegen, optionally prepared for bailouts. | 205 // BASE is generated by the full codegen, optionally prepared for bailouts. |
194 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 206 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
195 // NONOPT is generated by the full codegen and is not prepared for | 207 // NONOPT is generated by the full codegen and is not prepared for |
196 // recompilation/bailouts. These functions are never recompiled. | 208 // recompilation/bailouts. These functions are never recompiled. |
197 enum Mode { | 209 enum Mode { |
198 BASE, | 210 BASE, |
199 OPTIMIZE, | 211 OPTIMIZE, |
200 NONOPT | 212 NONOPT |
201 }; | 213 }; |
202 | 214 |
203 void Initialize(Mode mode) { | 215 void Initialize(Zone* zone); |
204 mode_ = V8::UseCrankshaft() ? mode : NONOPT; | |
205 ASSERT(!script_.is_null()); | |
206 if (script_->type()->value() == Script::TYPE_NATIVE) { | |
207 MarkAsNative(); | |
208 } | |
209 if (!shared_info_.is_null()) { | |
210 ASSERT(language_mode() == CLASSIC_MODE); | |
211 SetLanguageMode(shared_info_->language_mode()); | |
212 } | |
213 set_bailout_reason("unknown"); | |
214 } | |
215 | 216 |
216 void SetMode(Mode mode) { | 217 void SetMode(Mode mode) { |
217 ASSERT(V8::UseCrankshaft()); | 218 ASSERT(V8::UseCrankshaft()); |
218 mode_ = mode; | 219 mode_ = mode; |
219 } | 220 } |
220 | 221 |
221 // Flags using template class BitField<type, start, length>. All are | 222 // Flags using template class BitField<type, start, length>. All are |
222 // false by default. | 223 // false by default. |
223 // | 224 // |
224 // Compilation is either eager or lazy. | 225 // Compilation is either eager or lazy. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 template<typename T> | 279 template<typename T> |
279 void SaveHandle(Handle<T> *object) { | 280 void SaveHandle(Handle<T> *object) { |
280 if (!object->is_null()) { | 281 if (!object->is_null()) { |
281 Handle<T> handle(*(*object)); | 282 Handle<T> handle(*(*object)); |
282 *object = handle; | 283 *object = handle; |
283 } | 284 } |
284 } | 285 } |
285 | 286 |
286 const char* bailout_reason_; | 287 const char* bailout_reason_; |
287 | 288 |
| 289 int prologue_offset_; |
| 290 |
288 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); | 291 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); |
289 }; | 292 }; |
290 | 293 |
291 | 294 |
292 // Exactly like a CompilationInfo, except also creates and enters a | 295 // Exactly like a CompilationInfo, except also creates and enters a |
293 // Zone on construction and deallocates it on exit. | 296 // Zone on construction and deallocates it on exit. |
294 class CompilationInfoWithZone: public CompilationInfo { | 297 class CompilationInfoWithZone: public CompilationInfo { |
295 public: | 298 public: |
296 INLINE(void* operator new(size_t size)) { return Malloced::New(size); } | 299 INLINE(void* operator new(size_t size)) { return Malloced::New(size); } |
297 | 300 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 473 |
471 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 474 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
472 CompilationInfo* info, | 475 CompilationInfo* info, |
473 Handle<SharedFunctionInfo> shared); | 476 Handle<SharedFunctionInfo> shared); |
474 }; | 477 }; |
475 | 478 |
476 | 479 |
477 } } // namespace v8::internal | 480 } } // namespace v8::internal |
478 | 481 |
479 #endif // V8_COMPILER_H_ | 482 #endif // V8_COMPILER_H_ |
OLD | NEW |