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

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

Issue 21089006: Allocation space decisions are precisely made in hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | « 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 5222 matching lines...) Expand 10 before | Expand all | Expand 10 after
5233 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) 5233 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
5234 5234
5235 private: 5235 private:
5236 Handle<Object> name_; 5236 Handle<Object> name_;
5237 bool for_typeof_; 5237 bool for_typeof_;
5238 }; 5238 };
5239 5239
5240 5240
5241 class HAllocate: public HTemplateInstruction<2> { 5241 class HAllocate: public HTemplateInstruction<2> {
5242 public: 5242 public:
5243 enum Flags { 5243 HAllocate(HValue* context,
5244 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, 5244 HValue* size,
5245 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5245 HType type,
5246 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5246 bool pretenure,
5247 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5247 ElementsKind kind = FAST_ELEMENTS) {
5248 PREFILL_WITH_FILLER = 1 << 4
5249 };
5250
5251 HAllocate(HValue* context, HValue* size, HType type, Flags flags)
5252 : flags_(flags) {
5253 SetOperandAt(0, context); 5248 SetOperandAt(0, context);
5254 SetOperandAt(1, size); 5249 SetOperandAt(1, size);
5255 set_type(type); 5250 set_type(type);
5256 set_representation(Representation::Tagged()); 5251 set_representation(Representation::Tagged());
5257 SetFlag(kTrackSideEffectDominators); 5252 SetFlag(kTrackSideEffectDominators);
5258 SetGVNFlag(kChangesNewSpacePromotion); 5253 SetGVNFlag(kChangesNewSpacePromotion);
5259 SetGVNFlag(kDependsOnNewSpacePromotion); 5254 SetGVNFlag(kDependsOnNewSpacePromotion);
5255 if (pretenure) {
5256 if (IsFastDoubleElementsKind(kind)) {
5257 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE |
5258 ALLOCATE_DOUBLE_ALIGNED);
5259 } else {
5260 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE;
5261 }
5262 } else {
5263 flags_ = ALLOCATE_IN_NEW_SPACE;
5264 if (IsFastDoubleElementsKind(kind)) {
5265 flags_ = static_cast<HAllocate::Flags>(flags_ |
5266 ALLOCATE_DOUBLE_ALIGNED);
5267 }
5268 }
5260 } 5269 }
5261 5270
5262 // Maximum instance size for which allocations will be inlined. 5271 // Maximum instance size for which allocations will be inlined.
5263 static const int kMaxInlineSize = 64 * kPointerSize; 5272 static const int kMaxInlineSize = 64 * kPointerSize;
5264 5273
5265 static Flags DefaultFlags() {
5266 return CAN_ALLOCATE_IN_NEW_SPACE;
5267 }
5268
5269 static Flags DefaultFlags(ElementsKind kind) {
5270 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE;
5271 if (IsFastDoubleElementsKind(kind)) {
5272 flags = static_cast<HAllocate::Flags>(
5273 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
5274 }
5275 return flags;
5276 }
5277
5278 HValue* context() { return OperandAt(0); } 5274 HValue* context() { return OperandAt(0); }
5279 HValue* size() { return OperandAt(1); } 5275 HValue* size() { return OperandAt(1); }
5280 5276
5281 virtual Representation RequiredInputRepresentation(int index) { 5277 virtual Representation RequiredInputRepresentation(int index) {
5282 if (index == 0) { 5278 if (index == 0) {
5283 return Representation::Tagged(); 5279 return Representation::Tagged();
5284 } else { 5280 } else {
5285 return Representation::Integer32(); 5281 return Representation::Integer32();
5286 } 5282 }
5287 } 5283 }
5288 5284
5289 virtual Handle<Map> GetMonomorphicJSObjectMap() { 5285 virtual Handle<Map> GetMonomorphicJSObjectMap() {
5290 return known_initial_map_; 5286 return known_initial_map_;
5291 } 5287 }
5292 5288
5293 void set_known_initial_map(Handle<Map> known_initial_map) { 5289 void set_known_initial_map(Handle<Map> known_initial_map) {
5294 known_initial_map_ = known_initial_map; 5290 known_initial_map_ = known_initial_map;
5295 } 5291 }
5296 5292
5297 bool CanAllocateInNewSpace() const { 5293 bool IsNewSpaceAllocation() const {
5298 return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0; 5294 return (flags_ & ALLOCATE_IN_NEW_SPACE) != 0;
5299 } 5295 }
5300 5296
5301 bool CanAllocateInOldDataSpace() const { 5297 bool IsOldDataSpaceAllocation() const {
5302 return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0; 5298 return (flags_ & ALLOCATE_IN_OLD_DATA_SPACE) != 0;
5303 } 5299 }
5304 5300
5305 bool CanAllocateInOldPointerSpace() const { 5301 bool IsOldPointerSpaceAllocation() const {
5306 return (flags_ & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) != 0; 5302 return (flags_ & ALLOCATE_IN_OLD_POINTER_SPACE) != 0;
5307 }
5308
5309 bool CanAllocateInOldSpace() const {
5310 return CanAllocateInOldDataSpace() ||
5311 CanAllocateInOldPointerSpace();
5312 }
5313
5314 bool GuaranteedInNewSpace() const {
5315 return CanAllocateInNewSpace() && !CanAllocateInOldSpace();
5316 } 5303 }
5317 5304
5318 bool MustAllocateDoubleAligned() const { 5305 bool MustAllocateDoubleAligned() const {
5319 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; 5306 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0;
5320 } 5307 }
5321 5308
5322 bool MustPrefillWithFiller() const { 5309 bool MustPrefillWithFiller() const {
5323 return (flags_ & PREFILL_WITH_FILLER) != 0; 5310 return (flags_ & PREFILL_WITH_FILLER) != 0;
5324 } 5311 }
5325 5312
5326 void SetFlags(Flags flags) { 5313 void MakePrefillWithFiller() {
5327 flags_ = static_cast<HAllocate::Flags>(flags_ | flags); 5314 flags_ = static_cast<HAllocate::Flags>(flags_ | PREFILL_WITH_FILLER);
5315 }
5316
5317 void MakeDoubleAligned() {
5318 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED);
5328 } 5319 }
5329 5320
5330 void UpdateSize(HValue* size) { 5321 void UpdateSize(HValue* size) {
5331 SetOperandAt(1, size); 5322 SetOperandAt(1, size);
5332 } 5323 }
5333 5324
5334 virtual void HandleSideEffectDominator(GVNFlag side_effect, 5325 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5335 HValue* dominator); 5326 HValue* dominator);
5336 5327
5337 virtual void PrintDataTo(StringStream* stream); 5328 virtual void PrintDataTo(StringStream* stream);
5338 5329
5339 DECLARE_CONCRETE_INSTRUCTION(Allocate) 5330 DECLARE_CONCRETE_INSTRUCTION(Allocate)
5340 5331
5341 private: 5332 private:
5333 enum Flags {
5334 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5335 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5336 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5337 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5338 PREFILL_WITH_FILLER = 1 << 4
5339 };
5340
5342 Flags flags_; 5341 Flags flags_;
5343 Handle<Map> known_initial_map_; 5342 Handle<Map> known_initial_map_;
5344 }; 5343 };
5345 5344
5346 5345
5347 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5346 class HInnerAllocatedObject: public HTemplateInstruction<1> {
5348 public: 5347 public:
5349 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) 5348 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
5350 : offset_(offset) { 5349 : offset_(offset) {
5351 ASSERT(value->IsAllocate()); 5350 ASSERT(value->IsAllocate());
(...skipping 30 matching lines...) Expand all
5382 if (object->IsInnerAllocatedObject()) { 5381 if (object->IsInnerAllocatedObject()) {
5383 return ReceiverObjectNeedsWriteBarrier( 5382 return ReceiverObjectNeedsWriteBarrier(
5384 HInnerAllocatedObject::cast(object)->base_object(), 5383 HInnerAllocatedObject::cast(object)->base_object(),
5385 new_space_dominator); 5384 new_space_dominator);
5386 } 5385 }
5387 if (object->IsConstant() && HConstant::cast(object)->IsCell()) { 5386 if (object->IsConstant() && HConstant::cast(object)->IsCell()) {
5388 return false; 5387 return false;
5389 } 5388 }
5390 if (object != new_space_dominator) return true; 5389 if (object != new_space_dominator) return true;
5391 if (object->IsAllocate()) { 5390 if (object->IsAllocate()) {
5392 return !HAllocate::cast(object)->GuaranteedInNewSpace(); 5391 return !HAllocate::cast(object)->IsNewSpaceAllocation();
5393 } 5392 }
5394 return true; 5393 return true;
5395 } 5394 }
5396 5395
5397 5396
5398 class HStoreGlobalCell: public HUnaryOperation { 5397 class HStoreGlobalCell: public HUnaryOperation {
5399 public: 5398 public:
5400 HStoreGlobalCell(HValue* value, 5399 HStoreGlobalCell(HValue* value,
5401 Handle<PropertyCell> cell, 5400 Handle<PropertyCell> cell,
5402 PropertyDetails details) 5401 PropertyDetails details)
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after
7006 virtual bool IsDeletable() const { return true; } 7005 virtual bool IsDeletable() const { return true; }
7007 }; 7006 };
7008 7007
7009 7008
7010 #undef DECLARE_INSTRUCTION 7009 #undef DECLARE_INSTRUCTION
7011 #undef DECLARE_CONCRETE_INSTRUCTION 7010 #undef DECLARE_CONCRETE_INSTRUCTION
7012 7011
7013 } } // namespace v8::internal 7012 } } // namespace v8::internal
7014 7013
7015 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7014 #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