Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: src/compiler.h

Issue 18022002: Move phase_zone from CompilationInfo to CompilationPhase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 struct OffsetRange { 50 struct OffsetRange {
51 OffsetRange(int from, int to) : from(from), to(to) {} 51 OffsetRange(int from, int to) : from(from), to(to) {}
52 int from; 52 int from;
53 int to; 53 int to;
54 }; 54 };
55 55
56 // CompilationInfo encapsulates some information known at compile time. It 56 // CompilationInfo encapsulates some information known at compile time. It
57 // is constructed based on the resources available at compile-time. 57 // is constructed based on the resources available at compile-time.
58 class CompilationInfo { 58 class CompilationInfo {
59 public: 59 public:
60 CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_zone); 60 CompilationInfo(Handle<JSFunction> closure, Zone* zone);
61 virtual ~CompilationInfo(); 61 virtual ~CompilationInfo();
62 62
63 Isolate* isolate() { 63 Isolate* isolate() {
64 ASSERT(Isolate::Current() == isolate_); 64 ASSERT(Isolate::Current() == isolate_);
65 return isolate_; 65 return isolate_;
66 } 66 }
67 Zone* zone() { return zone_; } 67 Zone* zone() { return zone_; }
68 Zone* phase_zone() { return phase_zone_; }
69 bool is_lazy() const { return IsLazy::decode(flags_); } 68 bool is_lazy() const { return IsLazy::decode(flags_); }
70 bool is_eval() const { return IsEval::decode(flags_); } 69 bool is_eval() const { return IsEval::decode(flags_); }
71 bool is_global() const { return IsGlobal::decode(flags_); } 70 bool is_global() const { return IsGlobal::decode(flags_); }
72 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } 71 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
73 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } 72 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; }
74 LanguageMode language_mode() const { 73 LanguageMode language_mode() const {
75 return LanguageModeField::decode(flags_); 74 return LanguageModeField::decode(flags_);
76 } 75 }
77 bool is_in_loop() const { return IsInLoop::decode(flags_); } 76 bool is_in_loop() const { return IsInLoop::decode(flags_); }
78 FunctionLiteral* function() const { return function_; } 77 FunctionLiteral* function() const { return function_; }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 void AbortDueToDependencyChange() { 295 void AbortDueToDependencyChange() {
297 mode_ = DEPENDENCY_CHANGE_ABORT; 296 mode_ = DEPENDENCY_CHANGE_ABORT;
298 } 297 }
299 298
300 bool HasAbortedDueToDependencyChange() { 299 bool HasAbortedDueToDependencyChange() {
301 return mode_ == DEPENDENCY_CHANGE_ABORT; 300 return mode_ == DEPENDENCY_CHANGE_ABORT;
302 } 301 }
303 302
304 protected: 303 protected:
305 CompilationInfo(Handle<Script> script, 304 CompilationInfo(Handle<Script> script,
306 Zone* zone, 305 Zone* zone);
307 Zone* phase_zone);
308 CompilationInfo(Handle<SharedFunctionInfo> shared_info, 306 CompilationInfo(Handle<SharedFunctionInfo> shared_info,
309 Zone* zone, 307 Zone* zone);
310 Zone* phase_zone);
311 CompilationInfo(HydrogenCodeStub* stub, 308 CompilationInfo(HydrogenCodeStub* stub,
312 Isolate* isolate, 309 Isolate* isolate,
313 Zone* zone, 310 Zone* zone);
314 Zone* phase_zone);
315 311
316 private: 312 private:
317 Isolate* isolate_; 313 Isolate* isolate_;
318 314
319 // Compilation mode. 315 // Compilation mode.
320 // BASE is generated by the full codegen, optionally prepared for bailouts. 316 // BASE is generated by the full codegen, optionally prepared for bailouts.
321 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 317 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
322 // NONOPT is generated by the full codegen and is not prepared for 318 // NONOPT is generated by the full codegen and is not prepared for
323 // recompilation/bailouts. These functions are never recompiled. 319 // recompilation/bailouts. These functions are never recompiled.
324 enum Mode { 320 enum Mode {
325 BASE, 321 BASE,
326 OPTIMIZE, 322 OPTIMIZE,
327 NONOPT, 323 NONOPT,
328 STUB, 324 STUB,
329 DEPENDENCY_CHANGE_ABORT 325 DEPENDENCY_CHANGE_ABORT
330 }; 326 };
331 327
332 void Initialize(Isolate* isolate, Mode mode, Zone* zone, Zone* phase_zone); 328 void Initialize(Isolate* isolate, Mode mode, Zone* zone);
333 329
334 void SetMode(Mode mode) { 330 void SetMode(Mode mode) {
335 ASSERT(V8::UseCrankshaft()); 331 ASSERT(V8::UseCrankshaft());
336 mode_ = mode; 332 mode_ = mode;
337 } 333 }
338 334
339 // Flags using template class BitField<type, start, length>. All are 335 // Flags using template class BitField<type, start, length>. All are
340 // false by default. 336 // false by default.
341 // 337 //
342 // Compilation is either eager or lazy. 338 // Compilation is either eager or lazy.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // global script. Will be a null handle otherwise. 392 // global script. Will be a null handle otherwise.
397 Handle<Context> context_; 393 Handle<Context> context_;
398 394
399 // Compilation mode flag and whether deoptimization is allowed. 395 // Compilation mode flag and whether deoptimization is allowed.
400 Mode mode_; 396 Mode mode_;
401 BailoutId osr_ast_id_; 397 BailoutId osr_ast_id_;
402 398
403 // The zone from which the compilation pipeline working on this 399 // The zone from which the compilation pipeline working on this
404 // CompilationInfo allocates. 400 // CompilationInfo allocates.
405 Zone* zone_; 401 Zone* zone_;
406 // The phase zone where allocations local to a specific phase are
407 // performed; be aware that this zone is cleared after each phase
408 Zone* phase_zone_;
409 402
410 DeferredHandles* deferred_handles_; 403 DeferredHandles* deferred_handles_;
411 404
412 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount]; 405 ZoneList<Handle<HeapObject> >* dependencies_[DependentCode::kGroupCount];
413 406
414 template<typename T> 407 template<typename T>
415 void SaveHandle(Handle<T> *object) { 408 void SaveHandle(Handle<T> *object) {
416 if (!object->is_null()) { 409 if (!object->is_null()) {
417 Handle<T> handle(*(*object)); 410 Handle<T> handle(*(*object));
418 *object = handle; 411 *object = handle;
(...skipping 14 matching lines...) Expand all
433 426
434 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 427 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
435 }; 428 };
436 429
437 430
438 // Exactly like a CompilationInfo, except also creates and enters a 431 // Exactly like a CompilationInfo, except also creates and enters a
439 // Zone on construction and deallocates it on exit. 432 // Zone on construction and deallocates it on exit.
440 class CompilationInfoWithZone: public CompilationInfo { 433 class CompilationInfoWithZone: public CompilationInfo {
441 public: 434 public:
442 explicit CompilationInfoWithZone(Handle<Script> script) 435 explicit CompilationInfoWithZone(Handle<Script> script)
443 : CompilationInfo(script, &zone_, &phase_zone_), 436 : CompilationInfo(script, &zone_),
444 zone_(script->GetIsolate()), 437 zone_(script->GetIsolate()) {}
445 phase_zone_(script->GetIsolate()) {}
446 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 438 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
447 : CompilationInfo(shared_info, &zone_, &phase_zone_), 439 : CompilationInfo(shared_info, &zone_),
448 zone_(shared_info->GetIsolate()), 440 zone_(shared_info->GetIsolate()) {}
449 phase_zone_(shared_info->GetIsolate()) {}
450 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 441 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
451 : CompilationInfo(closure, &zone_, &phase_zone_), 442 : CompilationInfo(closure, &zone_),
452 zone_(closure->GetIsolate()), 443 zone_(closure->GetIsolate()) {}
453 phase_zone_(closure->GetIsolate()) {}
454 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 444 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
455 : CompilationInfo(stub, isolate, &zone_, &phase_zone_), 445 : CompilationInfo(stub, isolate, &zone_),
456 zone_(isolate), 446 zone_(isolate) {}
457 phase_zone_(isolate) {}
458 447
459 // Virtual destructor because a CompilationInfoWithZone has to exit the 448 // Virtual destructor because a CompilationInfoWithZone has to exit the
460 // 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
461 // called when cast as a CompilationInfo. 450 // called when cast as a CompilationInfo.
462 virtual ~CompilationInfoWithZone() { 451 virtual ~CompilationInfoWithZone() {
463 RollbackDependencies(); 452 RollbackDependencies();
464 } 453 }
465 454
466 private: 455 private:
467 Zone zone_; 456 Zone zone_;
468 Zone phase_zone_;
469 }; 457 };
470 458
471 459
472 // A wrapper around a CompilationInfo that detaches the Handles from 460 // A wrapper around a CompilationInfo that detaches the Handles from
473 // the underlying DeferredHandleScope and stores them in info_ on 461 // the underlying DeferredHandleScope and stores them in info_ on
474 // destruction. 462 // destruction.
475 class CompilationHandleScope BASE_EMBEDDED { 463 class CompilationHandleScope BASE_EMBEDDED {
476 public: 464 public:
477 explicit CompilationHandleScope(CompilationInfo* info) 465 explicit CompilationHandleScope(CompilationInfo* info)
478 : deferred_(info->isolate()), info_(info) {} 466 : deferred_(info->isolate()), info_(info) {}
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 #endif 612 #endif
625 613
626 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 614 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
627 CompilationInfo* info, 615 CompilationInfo* info,
628 Handle<SharedFunctionInfo> shared); 616 Handle<SharedFunctionInfo> shared);
629 }; 617 };
630 618
631 619
632 class CompilationPhase BASE_EMBEDDED { 620 class CompilationPhase BASE_EMBEDDED {
633 public: 621 public:
634 CompilationPhase(const char* name, Isolate* isolate, Zone* zone); 622 CompilationPhase(const char* name, CompilationInfo* info);
635 ~CompilationPhase(); 623 ~CompilationPhase();
636 624
637 protected: 625 protected:
638 bool ShouldProduceTraceOutput() const; 626 bool ShouldProduceTraceOutput() const;
639 627
640 const char* name() const { return name_; } 628 const char* name() const { return name_; }
641 Isolate* isolate() const { return isolate_; } 629 Isolate* isolate() const { return info_->isolate(); }
642 Zone* zone() const { return zone_; } 630 Zone* zone() { return &zone_; }
643 631
644 private: 632 private:
645 const char* name_; 633 const char* name_;
646 Isolate* isolate_; 634 CompilationInfo* info_;
647 Zone* zone_; 635 Zone zone_;
648 unsigned start_allocation_size_; 636 unsigned info_zone_start_allocation_size_;
649 int64_t start_ticks_; 637 int64_t start_ticks_;
650 638
651 DISALLOW_COPY_AND_ASSIGN(CompilationPhase); 639 DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
652 }; 640 };
653 641
654 642
655 } } // namespace v8::internal 643 } } // namespace v8::internal
656 644
657 #endif // V8_COMPILER_H_ 645 #endif // V8_COMPILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698