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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 // Disable all optimization attempts of this info for the rest of the | 233 // Disable all optimization attempts of this info for the rest of the |
234 // current compilation pipeline. | 234 // current compilation pipeline. |
235 void AbortOptimization(); | 235 void AbortOptimization(); |
236 | 236 |
237 void set_deferred_handles(DeferredHandles* deferred_handles) { | 237 void set_deferred_handles(DeferredHandles* deferred_handles) { |
238 ASSERT(deferred_handles_ == NULL); | 238 ASSERT(deferred_handles_ == NULL); |
239 deferred_handles_ = deferred_handles; | 239 deferred_handles_ = deferred_handles; |
240 } | 240 } |
241 | 241 |
242 ZoneList<Handle<Map> >* dependent_maps(DependentCode::DependencyGroup group) { | 242 ZoneList<Handle<HeapObject> >* dependencies( |
243 if (dependent_maps_[group] == NULL) { | 243 DependentCode::DependencyGroup group) { |
244 dependent_maps_[group] = new(zone_) ZoneList<Handle<Map> >(2, zone_); | 244 if (dependencies_[group] == NULL) { |
| 245 dependencies_[group] = new(zone_) ZoneList<Handle<HeapObject> >(2, zone_); |
245 } | 246 } |
246 return dependent_maps_[group]; | 247 return dependencies_[group]; |
247 } | 248 } |
248 | 249 |
249 void CommitDependentMaps(Handle<Code> code); | 250 void CommitDependencies(Handle<Code> code); |
250 | 251 |
251 void RollbackDependentMaps(); | 252 void RollbackDependencies(); |
252 | 253 |
253 void SaveHandles() { | 254 void SaveHandles() { |
254 SaveHandle(&closure_); | 255 SaveHandle(&closure_); |
255 SaveHandle(&shared_info_); | 256 SaveHandle(&shared_info_); |
256 SaveHandle(&context_); | 257 SaveHandle(&context_); |
257 SaveHandle(&script_); | 258 SaveHandle(&script_); |
258 } | 259 } |
259 | 260 |
260 const char* bailout_reason() const { return bailout_reason_; } | 261 const char* bailout_reason() const { return bailout_reason_; } |
261 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; } | 262 void set_bailout_reason(const char* reason) { bailout_reason_ = reason; } |
(...skipping 22 matching lines...) Expand all Loading... |
284 } | 285 } |
285 | 286 |
286 Handle<Foreign> object_wrapper() { | 287 Handle<Foreign> object_wrapper() { |
287 if (object_wrapper_.is_null()) { | 288 if (object_wrapper_.is_null()) { |
288 object_wrapper_ = | 289 object_wrapper_ = |
289 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); | 290 isolate()->factory()->NewForeign(reinterpret_cast<Address>(this)); |
290 } | 291 } |
291 return object_wrapper_; | 292 return object_wrapper_; |
292 } | 293 } |
293 | 294 |
294 void AbortDueToDependentMap() { | 295 void AbortDueToDependencyChange() { |
295 mode_ = DEPENDENT_MAP_ABORT; | 296 mode_ = DEPENDENCY_CHANGE_ABORT; |
296 } | 297 } |
297 | 298 |
298 bool HasAbortedDueToDependentMap() { | 299 bool HasAbortedDueToDependencyChange() { |
299 return mode_ == DEPENDENT_MAP_ABORT; | 300 return mode_ == DEPENDENCY_CHANGE_ABORT; |
300 } | 301 } |
301 | 302 |
302 protected: | 303 protected: |
303 CompilationInfo(Handle<Script> script, Zone* zone); | 304 CompilationInfo(Handle<Script> script, Zone* zone); |
304 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); | 305 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); |
305 CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone); | 306 CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone); |
306 | 307 |
307 private: | 308 private: |
308 Isolate* isolate_; | 309 Isolate* isolate_; |
309 | 310 |
310 // Compilation mode. | 311 // Compilation mode. |
311 // BASE is generated by the full codegen, optionally prepared for bailouts. | 312 // BASE is generated by the full codegen, optionally prepared for bailouts. |
312 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. | 313 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. |
313 // NONOPT is generated by the full codegen and is not prepared for | 314 // NONOPT is generated by the full codegen and is not prepared for |
314 // recompilation/bailouts. These functions are never recompiled. | 315 // recompilation/bailouts. These functions are never recompiled. |
315 enum Mode { | 316 enum Mode { |
316 BASE, | 317 BASE, |
317 OPTIMIZE, | 318 OPTIMIZE, |
318 NONOPT, | 319 NONOPT, |
319 STUB, | 320 STUB, |
320 DEPENDENT_MAP_ABORT | 321 DEPENDENCY_CHANGE_ABORT |
321 }; | 322 }; |
322 | 323 |
323 void Initialize(Isolate* isolate, Mode mode, Zone* zone); | 324 void Initialize(Isolate* isolate, Mode mode, Zone* zone); |
324 | 325 |
325 void SetMode(Mode mode) { | 326 void SetMode(Mode mode) { |
326 ASSERT(V8::UseCrankshaft()); | 327 ASSERT(V8::UseCrankshaft()); |
327 mode_ = mode; | 328 mode_ = mode; |
328 } | 329 } |
329 | 330 |
330 // Flags using template class BitField<type, start, length>. All are | 331 // Flags using template class BitField<type, start, length>. All are |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Compilation mode flag and whether deoptimization is allowed. | 391 // Compilation mode flag and whether deoptimization is allowed. |
391 Mode mode_; | 392 Mode mode_; |
392 BailoutId osr_ast_id_; | 393 BailoutId osr_ast_id_; |
393 | 394 |
394 // The zone from which the compilation pipeline working on this | 395 // The zone from which the compilation pipeline working on this |
395 // CompilationInfo allocates. | 396 // CompilationInfo allocates. |
396 Zone* zone_; | 397 Zone* zone_; |
397 | 398 |
398 DeferredHandles* deferred_handles_; | 399 DeferredHandles* deferred_handles_; |
399 | 400 |
400 ZoneList<Handle<Map> >* dependent_maps_[DependentCode::kGroupCount]; | 401 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; |
401 | 402 |
402 template<typename T> | 403 template<typename T> |
403 void SaveHandle(Handle<T> *object) { | 404 void SaveHandle(Handle<T> *object) { |
404 if (!object->is_null()) { | 405 if (!object->is_null()) { |
405 Handle<T> handle(*(*object)); | 406 Handle<T> handle(*(*object)); |
406 *object = handle; | 407 *object = handle; |
407 } | 408 } |
408 } | 409 } |
409 | 410 |
410 const char* bailout_reason_; | 411 const char* bailout_reason_; |
(...skipping 30 matching lines...) Expand all Loading... |
441 zone_scope_(&zone_, DELETE_ON_EXIT) {} | 442 zone_scope_(&zone_, DELETE_ON_EXIT) {} |
442 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) | 443 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) |
443 : CompilationInfo(stub, isolate, &zone_), | 444 : CompilationInfo(stub, isolate, &zone_), |
444 zone_(isolate), | 445 zone_(isolate), |
445 zone_scope_(&zone_, DELETE_ON_EXIT) {} | 446 zone_scope_(&zone_, DELETE_ON_EXIT) {} |
446 | 447 |
447 // Virtual destructor because a CompilationInfoWithZone has to exit the | 448 // Virtual destructor because a CompilationInfoWithZone has to exit the |
448 // zone scope and get rid of dependent maps even when the destructor is | 449 // zone scope and get rid of dependent maps even when the destructor is |
449 // called when cast as a CompilationInfo. | 450 // called when cast as a CompilationInfo. |
450 virtual ~CompilationInfoWithZone() { | 451 virtual ~CompilationInfoWithZone() { |
451 RollbackDependentMaps(); | 452 RollbackDependencies(); |
452 } | 453 } |
453 | 454 |
454 private: | 455 private: |
455 Zone zone_; | 456 Zone zone_; |
456 ZoneScope zone_scope_; | 457 ZoneScope zone_scope_; |
457 }; | 458 }; |
458 | 459 |
459 | 460 |
460 // A wrapper around a CompilationInfo that detaches the Handles from | 461 // A wrapper around a CompilationInfo that detaches the Handles from |
461 // the underlying DeferredHandleScope and stores them in info_ on | 462 // the underlying DeferredHandleScope and stores them in info_ on |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 | 614 |
614 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, | 615 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
615 CompilationInfo* info, | 616 CompilationInfo* info, |
616 Handle<SharedFunctionInfo> shared); | 617 Handle<SharedFunctionInfo> shared); |
617 }; | 618 }; |
618 | 619 |
619 | 620 |
620 } } // namespace v8::internal | 621 } } // namespace v8::internal |
621 | 622 |
622 #endif // V8_COMPILER_H_ | 623 #endif // V8_COMPILER_H_ |
OLD | NEW |