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

Side by Side Diff: src/hydrogen-instructions.h

Issue 110443003: Make it possible to assert that certain instance types are compatible wrt HAllocate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Do not expose the flags. Created 7 years 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.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 5410 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 SetAllSideEffects(); 5421 SetAllSideEffects();
5422 } 5422 }
5423 5423
5424 Handle<Object> name_; 5424 Handle<Object> name_;
5425 bool for_typeof_; 5425 bool for_typeof_;
5426 }; 5426 };
5427 5427
5428 5428
5429 class HAllocate V8_FINAL : public HTemplateInstruction<2> { 5429 class HAllocate V8_FINAL : public HTemplateInstruction<2> {
5430 public: 5430 public:
5431 static bool CompatibleInstanceTypes(InstanceType type1,
5432 InstanceType type2) {
5433 return ComputeFlags(TENURED, type1) == ComputeFlags(TENURED, type2) &&
5434 ComputeFlags(NOT_TENURED, type1) == ComputeFlags(NOT_TENURED, type2);
5435 }
5436
5431 static HAllocate* New(Zone* zone, 5437 static HAllocate* New(Zone* zone,
5432 HValue* context, 5438 HValue* context,
5433 HValue* size, 5439 HValue* size,
5434 HType type, 5440 HType type,
5435 PretenureFlag pretenure_flag, 5441 PretenureFlag pretenure_flag,
5436 InstanceType instance_type, 5442 InstanceType instance_type,
5437 Handle<AllocationSite> allocation_site = 5443 Handle<AllocationSite> allocation_site =
5438 Handle<AllocationSite>::null()) { 5444 Handle<AllocationSite>::null()) {
5439 return new(zone) HAllocate(context, size, type, pretenure_flag, 5445 return new(zone) HAllocate(context, size, type, pretenure_flag,
5440 instance_type, allocation_site); 5446 instance_type, allocation_site);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5479 } 5485 }
5480 5486
5481 bool MustPrefillWithFiller() const { 5487 bool MustPrefillWithFiller() const {
5482 return (flags_ & PREFILL_WITH_FILLER) != 0; 5488 return (flags_ & PREFILL_WITH_FILLER) != 0;
5483 } 5489 }
5484 5490
5485 void MakePrefillWithFiller() { 5491 void MakePrefillWithFiller() {
5486 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); 5492 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER);
5487 } 5493 }
5488 5494
5495 bool MustClearNextMapWord() const {
5496 return (flags_ & CLEAR_NEXT_MAP_WORD) != 0;
5497 }
5498
5489 void MakeDoubleAligned() { 5499 void MakeDoubleAligned() {
5490 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); 5500 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED);
5491 } 5501 }
5492 5502
5493 virtual void HandleSideEffectDominator(GVNFlag side_effect, 5503 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5494 HValue* dominator) V8_OVERRIDE; 5504 HValue* dominator) V8_OVERRIDE;
5495 5505
5496 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 5506 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5497 5507
5498 DECLARE_CONCRETE_INSTRUCTION(Allocate) 5508 DECLARE_CONCRETE_INSTRUCTION(Allocate)
5499 5509
5500 private: 5510 private:
5501 enum Flags { 5511 enum Flags {
5502 ALLOCATE_IN_NEW_SPACE = 1 << 0, 5512 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5503 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5513 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5504 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5514 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5505 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5515 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5506 PREFILL_WITH_FILLER = 1 << 4 5516 PREFILL_WITH_FILLER = 1 << 4,
5517 CLEAR_NEXT_MAP_WORD = 1 << 5
5507 }; 5518 };
5508 5519
5509 HAllocate(HValue* context, 5520 HAllocate(HValue* context,
5510 HValue* size, 5521 HValue* size,
5511 HType type, 5522 HType type,
5512 PretenureFlag pretenure_flag, 5523 PretenureFlag pretenure_flag,
5513 InstanceType instance_type, 5524 InstanceType instance_type,
5514 Handle<AllocationSite> allocation_site = 5525 Handle<AllocationSite> allocation_site =
5515 Handle<AllocationSite>::null()) 5526 Handle<AllocationSite>::null())
5516 : HTemplateInstruction<2>(type), 5527 : HTemplateInstruction<2>(type),
5528 flags_(ComputeFlags(pretenure_flag, instance_type)),
5517 dominating_allocate_(NULL), 5529 dominating_allocate_(NULL),
5518 filler_free_space_size_(NULL), 5530 filler_free_space_size_(NULL) {
5519 clear_next_map_word_(false) {
5520 SetOperandAt(0, context); 5531 SetOperandAt(0, context);
5521 SetOperandAt(1, size); 5532 SetOperandAt(1, size);
5522 set_representation(Representation::Tagged()); 5533 set_representation(Representation::Tagged());
5523 SetFlag(kTrackSideEffectDominators); 5534 SetFlag(kTrackSideEffectDominators);
5524 SetGVNFlag(kChangesNewSpacePromotion); 5535 SetGVNFlag(kChangesNewSpacePromotion);
5525 SetGVNFlag(kDependsOnNewSpacePromotion); 5536 SetGVNFlag(kDependsOnNewSpacePromotion);
5526 flags_ = pretenure_flag == TENURED 5537
5538 if (FLAG_trace_pretenuring) {
5539 PrintF("HAllocate with AllocationSite %p %s\n",
5540 allocation_site.is_null()
5541 ? static_cast<void*>(NULL)
5542 : static_cast<void*>(*allocation_site),
5543 pretenure_flag == TENURED ? "tenured" : "not tenured");
5544 }
5545 }
5546
5547 static Flags ComputeFlags(PretenureFlag pretenure_flag,
5548 InstanceType instance_type) {
5549 Flags flags = pretenure_flag == TENURED
5527 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE 5550 ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE
5528 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE) 5551 ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE)
5529 : ALLOCATE_IN_NEW_SPACE; 5552 : ALLOCATE_IN_NEW_SPACE;
5530 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { 5553 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
5531 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); 5554 flags = static_cast<Flags>(flags | ALLOCATE_DOUBLE_ALIGNED);
5532 } 5555 }
5533 // We have to fill the allocated object with one word fillers if we do 5556 // We have to fill the allocated object with one word fillers if we do
5534 // not use allocation folding since some allocations may depend on each 5557 // not use allocation folding since some allocations may depend on each
5535 // other, i.e., have a pointer to each other. A GC in between these 5558 // other, i.e., have a pointer to each other. A GC in between these
5536 // allocations may leave such objects behind in a not completely initialized 5559 // allocations may leave such objects behind in a not completely initialized
5537 // state. 5560 // state.
5538 if (!FLAG_use_gvn || !FLAG_use_allocation_folding) { 5561 if (!FLAG_use_gvn || !FLAG_use_allocation_folding) {
5539 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER); 5562 flags = static_cast<Flags>(flags | PREFILL_WITH_FILLER);
5540 } 5563 }
5541 clear_next_map_word_ = pretenure_flag == NOT_TENURED && 5564 if (pretenure_flag == NOT_TENURED &&
5542 AllocationSite::CanTrack(instance_type); 5565 AllocationSite::CanTrack(instance_type)) {
5566 flags = static_cast<Flags>(flags | CLEAR_NEXT_MAP_WORD);
5567 }
5568 return flags;
5569 }
5543 5570
5544 if (FLAG_trace_pretenuring) { 5571 void UpdateClearNextMapWord(bool clear_next_map_word) {
5545 PrintF("HAllocate with AllocationSite %p %s\n", 5572 flags_ = static_cast<Flags>(clear_next_map_word
5546 allocation_site.is_null() 5573 ? flags_ | CLEAR_NEXT_MAP_WORD
5547 ? static_cast<void*>(NULL) 5574 : flags_ & ~CLEAR_NEXT_MAP_WORD);
5548 : static_cast<void*>(*allocation_site),
5549 pretenure_flag == TENURED ? "tenured" : "not tenured");
5550 }
5551 } 5575 }
5552 5576
5553 void UpdateSize(HValue* size) { 5577 void UpdateSize(HValue* size) {
5554 SetOperandAt(1, size); 5578 SetOperandAt(1, size);
5555 } 5579 }
5556 5580
5557 HAllocate* GetFoldableDominator(HAllocate* dominator); 5581 HAllocate* GetFoldableDominator(HAllocate* dominator);
5558 5582
5559 void UpdateFreeSpaceFiller(int32_t filler_size); 5583 void UpdateFreeSpaceFiller(int32_t filler_size);
5560 5584
5561 void CreateFreeSpaceFiller(int32_t filler_size); 5585 void CreateFreeSpaceFiller(int32_t filler_size);
5562 5586
5563 bool IsFoldable(HAllocate* allocate) { 5587 bool IsFoldable(HAllocate* allocate) {
5564 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) || 5588 return (IsNewSpaceAllocation() && allocate->IsNewSpaceAllocation()) ||
5565 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) || 5589 (IsOldDataSpaceAllocation() && allocate->IsOldDataSpaceAllocation()) ||
5566 (IsOldPointerSpaceAllocation() && 5590 (IsOldPointerSpaceAllocation() &&
5567 allocate->IsOldPointerSpaceAllocation()); 5591 allocate->IsOldPointerSpaceAllocation());
5568 } 5592 }
5569 5593
5570 void ClearNextMapWord(int offset); 5594 void ClearNextMapWord(int offset);
5571 5595
5572 Flags flags_; 5596 Flags flags_;
5573 Handle<Map> known_initial_map_; 5597 Handle<Map> known_initial_map_;
5574 HAllocate* dominating_allocate_; 5598 HAllocate* dominating_allocate_;
5575 HStoreNamedField* filler_free_space_size_; 5599 HStoreNamedField* filler_free_space_size_;
5576 bool clear_next_map_word_;
5577 }; 5600 };
5578 5601
5579 5602
5580 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { 5603 class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> {
5581 public: 5604 public:
5582 static HStoreCodeEntry* New(Zone* zone, 5605 static HStoreCodeEntry* New(Zone* zone,
5583 HValue* context, 5606 HValue* context,
5584 HValue* function, 5607 HValue* function,
5585 HValue* code) { 5608 HValue* code) {
5586 return new(zone) HStoreCodeEntry(function, code); 5609 return new(zone) HStoreCodeEntry(function, code);
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
7493 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 7516 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
7494 }; 7517 };
7495 7518
7496 7519
7497 #undef DECLARE_INSTRUCTION 7520 #undef DECLARE_INSTRUCTION
7498 #undef DECLARE_CONCRETE_INSTRUCTION 7521 #undef DECLARE_CONCRETE_INSTRUCTION
7499 7522
7500 } } // namespace v8::internal 7523 } } // namespace v8::internal
7501 7524
7502 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7525 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698