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

Side by Side Diff: src/compiler.h

Issue 17573003: Add phase zone to CompilationInfo and use it in GVN pass. (Closed) Base URL: git@github.com:v8/v8.git@master
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
« 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); 60 CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_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_; }
68 bool is_lazy() const { return IsLazy::decode(flags_); } 69 bool is_lazy() const { return IsLazy::decode(flags_); }
69 bool is_eval() const { return IsEval::decode(flags_); } 70 bool is_eval() const { return IsEval::decode(flags_); }
70 bool is_global() const { return IsGlobal::decode(flags_); } 71 bool is_global() const { return IsGlobal::decode(flags_); }
71 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; } 72 bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
72 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; } 73 bool is_extended_mode() const { return language_mode() == EXTENDED_MODE; }
73 LanguageMode language_mode() const { 74 LanguageMode language_mode() const {
74 return LanguageModeField::decode(flags_); 75 return LanguageModeField::decode(flags_);
75 } 76 }
76 bool is_in_loop() const { return IsInLoop::decode(flags_); } 77 bool is_in_loop() const { return IsInLoop::decode(flags_); }
77 FunctionLiteral* function() const { return function_; } 78 FunctionLiteral* function() const { return function_; }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 294
294 void AbortDueToDependentMap() { 295 void AbortDueToDependentMap() {
295 mode_ = DEPENDENT_MAP_ABORT; 296 mode_ = DEPENDENT_MAP_ABORT;
296 } 297 }
297 298
298 bool HasAbortedDueToDependentMap() { 299 bool HasAbortedDueToDependentMap() {
299 return mode_ == DEPENDENT_MAP_ABORT; 300 return mode_ == DEPENDENT_MAP_ABORT;
300 } 301 }
301 302
302 protected: 303 protected:
303 CompilationInfo(Handle<Script> script, Zone* zone); 304 CompilationInfo(Handle<Script> script,
304 CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); 305 Zone* zone,
305 CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone); 306 Zone* phase_zone);
307 CompilationInfo(Handle<SharedFunctionInfo> shared_info,
308 Zone* zone,
309 Zone* phase_zone);
310 CompilationInfo(HydrogenCodeStub* stub,
311 Isolate* isolate,
312 Zone* zone,
313 Zone* phase_zone);
306 314
307 private: 315 private:
308 Isolate* isolate_; 316 Isolate* isolate_;
309 317
310 // Compilation mode. 318 // Compilation mode.
311 // BASE is generated by the full codegen, optionally prepared for bailouts. 319 // BASE is generated by the full codegen, optionally prepared for bailouts.
312 // OPTIMIZE is optimized code generated by the Hydrogen-based backend. 320 // OPTIMIZE is optimized code generated by the Hydrogen-based backend.
313 // NONOPT is generated by the full codegen and is not prepared for 321 // NONOPT is generated by the full codegen and is not prepared for
314 // recompilation/bailouts. These functions are never recompiled. 322 // recompilation/bailouts. These functions are never recompiled.
315 enum Mode { 323 enum Mode {
316 BASE, 324 BASE,
317 OPTIMIZE, 325 OPTIMIZE,
318 NONOPT, 326 NONOPT,
319 STUB, 327 STUB,
320 DEPENDENT_MAP_ABORT 328 DEPENDENT_MAP_ABORT
321 }; 329 };
322 330
323 void Initialize(Isolate* isolate, Mode mode, Zone* zone); 331 void Initialize(Isolate* isolate, Mode mode, Zone* zone, Zone* phase_zone);
324 332
325 void SetMode(Mode mode) { 333 void SetMode(Mode mode) {
326 ASSERT(V8::UseCrankshaft()); 334 ASSERT(V8::UseCrankshaft());
327 mode_ = mode; 335 mode_ = mode;
328 } 336 }
329 337
330 // Flags using template class BitField<type, start, length>. All are 338 // Flags using template class BitField<type, start, length>. All are
331 // false by default. 339 // false by default.
332 // 340 //
333 // Compilation is either eager or lazy. 341 // Compilation is either eager or lazy.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // global script. Will be a null handle otherwise. 395 // global script. Will be a null handle otherwise.
388 Handle<Context> context_; 396 Handle<Context> context_;
389 397
390 // Compilation mode flag and whether deoptimization is allowed. 398 // Compilation mode flag and whether deoptimization is allowed.
391 Mode mode_; 399 Mode mode_;
392 BailoutId osr_ast_id_; 400 BailoutId osr_ast_id_;
393 401
394 // The zone from which the compilation pipeline working on this 402 // The zone from which the compilation pipeline working on this
395 // CompilationInfo allocates. 403 // CompilationInfo allocates.
396 Zone* zone_; 404 Zone* zone_;
405 // The phase zone where allocations local to a specific phase are
406 // performed; be aware that this zone is cleared after each phase
407 Zone* phase_zone_;
397 408
398 DeferredHandles* deferred_handles_; 409 DeferredHandles* deferred_handles_;
399 410
400 ZoneList<Handle<Map> >* dependent_maps_[DependentCode::kGroupCount]; 411 ZoneList<Handle<Map> >* dependent_maps_[DependentCode::kGroupCount];
401 412
402 template<typename T> 413 template<typename T>
403 void SaveHandle(Handle<T> *object) { 414 void SaveHandle(Handle<T> *object) {
404 if (!object->is_null()) { 415 if (!object->is_null()) {
405 Handle<T> handle(*(*object)); 416 Handle<T> handle(*(*object));
406 *object = handle; 417 *object = handle;
(...skipping 14 matching lines...) Expand all
421 432
422 DISALLOW_COPY_AND_ASSIGN(CompilationInfo); 433 DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
423 }; 434 };
424 435
425 436
426 // Exactly like a CompilationInfo, except also creates and enters a 437 // Exactly like a CompilationInfo, except also creates and enters a
427 // Zone on construction and deallocates it on exit. 438 // Zone on construction and deallocates it on exit.
428 class CompilationInfoWithZone: public CompilationInfo { 439 class CompilationInfoWithZone: public CompilationInfo {
429 public: 440 public:
430 explicit CompilationInfoWithZone(Handle<Script> script) 441 explicit CompilationInfoWithZone(Handle<Script> script)
431 : CompilationInfo(script, &zone_), 442 : CompilationInfo(script, &zone_, &phase_zone_),
432 zone_(script->GetIsolate()), 443 zone_(script->GetIsolate()),
433 zone_scope_(&zone_, DELETE_ON_EXIT) {} 444 zone_scope_(&zone_, DELETE_ON_EXIT),
445 phase_zone_(script->GetIsolate()) {}
434 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) 446 explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
435 : CompilationInfo(shared_info, &zone_), 447 : CompilationInfo(shared_info, &zone_, &phase_zone_),
436 zone_(shared_info->GetIsolate()), 448 zone_(shared_info->GetIsolate()),
437 zone_scope_(&zone_, DELETE_ON_EXIT) {} 449 zone_scope_(&zone_, DELETE_ON_EXIT),
450 phase_zone_(shared_info->GetIsolate()) {}
438 explicit CompilationInfoWithZone(Handle<JSFunction> closure) 451 explicit CompilationInfoWithZone(Handle<JSFunction> closure)
439 : CompilationInfo(closure, &zone_), 452 : CompilationInfo(closure, &zone_, &phase_zone_),
440 zone_(closure->GetIsolate()), 453 zone_(closure->GetIsolate()),
441 zone_scope_(&zone_, DELETE_ON_EXIT) {} 454 zone_scope_(&zone_, DELETE_ON_EXIT),
455 phase_zone_(closure->GetIsolate()) {}
442 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) 456 CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
443 : CompilationInfo(stub, isolate, &zone_), 457 : CompilationInfo(stub, isolate, &zone_, &phase_zone_),
444 zone_(isolate), 458 zone_(isolate),
445 zone_scope_(&zone_, DELETE_ON_EXIT) {} 459 zone_scope_(&zone_, DELETE_ON_EXIT),
460 phase_zone_(isolate) {}
446 461
447 // Virtual destructor because a CompilationInfoWithZone has to exit the 462 // Virtual destructor because a CompilationInfoWithZone has to exit the
448 // zone scope and get rid of dependent maps even when the destructor is 463 // zone scope and get rid of dependent maps even when the destructor is
449 // called when cast as a CompilationInfo. 464 // called when cast as a CompilationInfo.
450 virtual ~CompilationInfoWithZone() { 465 virtual ~CompilationInfoWithZone() {
451 RollbackDependentMaps(); 466 RollbackDependentMaps();
452 } 467 }
453 468
454 private: 469 private:
455 Zone zone_; 470 Zone zone_;
456 ZoneScope zone_scope_; 471 ZoneScope zone_scope_;
472 Zone phase_zone_;
457 }; 473 };
458 474
459 475
460 // A wrapper around a CompilationInfo that detaches the Handles from 476 // A wrapper around a CompilationInfo that detaches the Handles from
461 // the underlying DeferredHandleScope and stores them in info_ on 477 // the underlying DeferredHandleScope and stores them in info_ on
462 // destruction. 478 // destruction.
463 class CompilationHandleScope BASE_EMBEDDED { 479 class CompilationHandleScope BASE_EMBEDDED {
464 public: 480 public:
465 explicit CompilationHandleScope(CompilationInfo* info) 481 explicit CompilationHandleScope(CompilationInfo* info)
466 : deferred_(info->isolate()), info_(info) {} 482 : deferred_(info->isolate()), info_(info) {}
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 629
614 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag, 630 static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
615 CompilationInfo* info, 631 CompilationInfo* info,
616 Handle<SharedFunctionInfo> shared); 632 Handle<SharedFunctionInfo> shared);
617 }; 633 };
618 634
619 635
620 } } // namespace v8::internal 636 } } // namespace v8::internal
621 637
622 #endif // V8_COMPILER_H_ 638 #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