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

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

Issue 8256016: Eliminate write barrier for global stores at compile time if value stored is a smi. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 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/arm/lithium-codegen-arm.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 bool IsJSObject() { 391 bool IsJSObject() {
392 ASSERT(type_ != kUninitialized); 392 ASSERT(type_ != kUninitialized);
393 return ((type_ & kJSObject) == kJSObject); 393 return ((type_ & kJSObject) == kJSObject);
394 } 394 }
395 395
396 bool IsUninitialized() { 396 bool IsUninitialized() {
397 return type_ == kUninitialized; 397 return type_ == kUninitialized;
398 } 398 }
399 399
400 bool IsHeapObject() {
401 ASSERT(type_ != kUninitialized);
402 return IsHeapNumber() || IsString() || IsNonPrimitive();
403 }
404
400 static HType TypeFromValue(Handle<Object> value); 405 static HType TypeFromValue(Handle<Object> value);
401 406
402 const char* ToString(); 407 const char* ToString();
403 const char* ToShortString(); 408 const char* ToShortString();
404 409
405 private: 410 private:
406 enum Type { 411 enum Type {
407 kTagged = 0x1, // 0000 0000 0000 0001 412 kTagged = 0x1, // 0000 0000 0000 0001
408 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 413 kTaggedPrimitive = 0x5, // 0000 0000 0000 0101
409 kTaggedNumber = 0xd, // 0000 0000 0000 1101 414 kTaggedNumber = 0xd, // 0000 0000 0000 1101
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 class HChange: public HUnaryOperation { 1099 class HChange: public HUnaryOperation {
1095 public: 1100 public:
1096 HChange(HValue* value, 1101 HChange(HValue* value,
1097 Representation to, 1102 Representation to,
1098 bool is_truncating, 1103 bool is_truncating,
1099 bool deoptimize_on_undefined) 1104 bool deoptimize_on_undefined)
1100 : HUnaryOperation(value) { 1105 : HUnaryOperation(value) {
1101 ASSERT(!value->representation().IsNone() && !to.IsNone()); 1106 ASSERT(!value->representation().IsNone() && !to.IsNone());
1102 ASSERT(!value->representation().Equals(to)); 1107 ASSERT(!value->representation().Equals(to));
1103 set_representation(to); 1108 set_representation(to);
1109 set_type(HType::TaggedNumber());
1104 SetFlag(kUseGVN); 1110 SetFlag(kUseGVN);
1105 if (deoptimize_on_undefined) SetFlag(kDeoptimizeOnUndefined); 1111 if (deoptimize_on_undefined) SetFlag(kDeoptimizeOnUndefined);
1106 if (is_truncating) SetFlag(kTruncatingToInt32); 1112 if (is_truncating) SetFlag(kTruncatingToInt32);
1107 } 1113 }
1108 1114
1109 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1115 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
1116 virtual HType CalculateInferredType();
1110 1117
1111 Representation from() { return value()->representation(); } 1118 Representation from() { return value()->representation(); }
1112 Representation to() { return representation(); } 1119 Representation to() { return representation(); }
1113 bool deoptimize_on_undefined() const { 1120 bool deoptimize_on_undefined() const {
1114 return CheckFlag(kDeoptimizeOnUndefined); 1121 return CheckFlag(kDeoptimizeOnUndefined);
1115 } 1122 }
1116 virtual Representation RequiredInputRepresentation(int index) { 1123 virtual Representation RequiredInputRepresentation(int index) {
1117 return from(); 1124 return from();
1118 } 1125 }
1119 1126
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 } 3260 }
3254 3261
3255 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) 3262 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
3256 3263
3257 private: 3264 private:
3258 Handle<Object> name_; 3265 Handle<Object> name_;
3259 bool for_typeof_; 3266 bool for_typeof_;
3260 }; 3267 };
3261 3268
3262 3269
3270 static inline bool StoringValueNeedsWriteBarrier(HValue* value) {
3271 return !value->type().IsBoolean()
3272 && !value->type().IsSmi()
3273 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable());
3274 }
3275
3276
3263 class HStoreGlobalCell: public HUnaryOperation { 3277 class HStoreGlobalCell: public HUnaryOperation {
3264 public: 3278 public:
3265 HStoreGlobalCell(HValue* value, 3279 HStoreGlobalCell(HValue* value,
3266 Handle<JSGlobalPropertyCell> cell, 3280 Handle<JSGlobalPropertyCell> cell,
3267 PropertyDetails details) 3281 PropertyDetails details)
3268 : HUnaryOperation(value), 3282 : HUnaryOperation(value),
3269 cell_(cell), 3283 cell_(cell),
3270 details_(details) { 3284 details_(details) {
3271 SetFlag(kChangesGlobalVars); 3285 SetFlag(kChangesGlobalVars);
3272 } 3286 }
3273 3287
3274 Handle<JSGlobalPropertyCell> cell() const { return cell_; } 3288 Handle<JSGlobalPropertyCell> cell() const { return cell_; }
3275 bool RequiresHoleCheck() { 3289 bool RequiresHoleCheck() {
3276 return !details_.IsDontDelete() || details_.IsReadOnly(); 3290 return !details_.IsDontDelete() || details_.IsReadOnly();
3277 } 3291 }
3292 bool NeedsWriteBarrier() {
3293 return StoringValueNeedsWriteBarrier(value());
3294 }
3278 3295
3279 virtual Representation RequiredInputRepresentation(int index) { 3296 virtual Representation RequiredInputRepresentation(int index) {
3280 return Representation::Tagged(); 3297 return Representation::Tagged();
3281 } 3298 }
3282 virtual void PrintDataTo(StringStream* stream); 3299 virtual void PrintDataTo(StringStream* stream);
3283 3300
3284 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) 3301 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
3285 3302
3286 private: 3303 private:
3287 Handle<JSGlobalPropertyCell> cell_; 3304 Handle<JSGlobalPropertyCell> cell_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 virtual bool DataEquals(HValue* other) { 3365 virtual bool DataEquals(HValue* other) {
3349 HLoadContextSlot* b = HLoadContextSlot::cast(other); 3366 HLoadContextSlot* b = HLoadContextSlot::cast(other);
3350 return (slot_index() == b->slot_index()); 3367 return (slot_index() == b->slot_index());
3351 } 3368 }
3352 3369
3353 private: 3370 private:
3354 int slot_index_; 3371 int slot_index_;
3355 }; 3372 };
3356 3373
3357 3374
3358 static inline bool StoringValueNeedsWriteBarrier(HValue* value) {
3359 return !value->type().IsBoolean()
3360 && !value->type().IsSmi()
3361 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable());
3362 }
3363
3364
3365 class HStoreContextSlot: public HTemplateInstruction<2> { 3375 class HStoreContextSlot: public HTemplateInstruction<2> {
3366 public: 3376 public:
3367 HStoreContextSlot(HValue* context, int slot_index, HValue* value) 3377 HStoreContextSlot(HValue* context, int slot_index, HValue* value)
3368 : slot_index_(slot_index) { 3378 : slot_index_(slot_index) {
3369 SetOperandAt(0, context); 3379 SetOperandAt(0, context);
3370 SetOperandAt(1, value); 3380 SetOperandAt(1, value);
3371 SetFlag(kChangesContextSlots); 3381 SetFlag(kChangesContextSlots);
3372 } 3382 }
3373 3383
3374 HValue* context() { return OperandAt(0); } 3384 HValue* context() { return OperandAt(0); }
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 return new Range(0, String::kMaxUC16CharCode); 3951 return new Range(0, String::kMaxUC16CharCode);
3942 } 3952 }
3943 }; 3953 };
3944 3954
3945 3955
3946 class HStringCharFromCode: public HTemplateInstruction<2> { 3956 class HStringCharFromCode: public HTemplateInstruction<2> {
3947 public: 3957 public:
3948 HStringCharFromCode(HValue* context, HValue* char_code) { 3958 HStringCharFromCode(HValue* context, HValue* char_code) {
3949 SetOperandAt(0, context); 3959 SetOperandAt(0, context);
3950 SetOperandAt(1, char_code); 3960 SetOperandAt(1, char_code);
3951 set_representation(Representation::Tagged()); 3961 set_representation(Representation::Tagged());
3952 SetFlag(kUseGVN); 3962 SetFlag(kUseGVN);
3953 } 3963 }
3954 3964
3955 virtual Representation RequiredInputRepresentation(int index) { 3965 virtual Representation RequiredInputRepresentation(int index) {
3956 return index == 0 3966 return index == 0
3957 ? Representation::Tagged() 3967 ? Representation::Tagged()
3958 : Representation::Integer32(); 3968 : Representation::Integer32();
3959 } 3969 }
3970 virtual HType CalculateInferredType();
3960 3971
3961 HValue* context() { return OperandAt(0); } 3972 HValue* context() { return OperandAt(0); }
3962 HValue* value() { return OperandAt(1); } 3973 HValue* value() { return OperandAt(1); }
3963 3974
3964 virtual bool DataEquals(HValue* other) { return true; } 3975 virtual bool DataEquals(HValue* other) { return true; }
3965 3976
3966 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) 3977 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode)
3967 }; 3978 };
3968 3979
3969 3980
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4027 4038
4028 HValue* context() { return OperandAt(0); } 4039 HValue* context() { return OperandAt(0); }
4029 Handle<FixedArray> constant_elements() const { return constant_elements_; } 4040 Handle<FixedArray> constant_elements() const { return constant_elements_; }
4030 int length() const { return length_; } 4041 int length() const { return length_; }
4031 4042
4032 bool IsCopyOnWrite() const; 4043 bool IsCopyOnWrite() const;
4033 4044
4034 virtual Representation RequiredInputRepresentation(int index) { 4045 virtual Representation RequiredInputRepresentation(int index) {
4035 return Representation::Tagged(); 4046 return Representation::Tagged();
4036 } 4047 }
4048 virtual HType CalculateInferredType();
4037 4049
4038 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral) 4050 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral)
4039 4051
4040 private: 4052 private:
4041 int length_; 4053 int length_;
4042 Handle<FixedArray> constant_elements_; 4054 Handle<FixedArray> constant_elements_;
4043 }; 4055 };
4044 4056
4045 4057
4046 class HObjectLiteral: public HMaterializedLiteral<1> { 4058 class HObjectLiteral: public HMaterializedLiteral<1> {
(...skipping 14 matching lines...) Expand all
4061 HValue* context() { return OperandAt(0); } 4073 HValue* context() { return OperandAt(0); }
4062 Handle<FixedArray> constant_properties() const { 4074 Handle<FixedArray> constant_properties() const {
4063 return constant_properties_; 4075 return constant_properties_;
4064 } 4076 }
4065 bool fast_elements() const { return fast_elements_; } 4077 bool fast_elements() const { return fast_elements_; }
4066 bool has_function() const { return has_function_; } 4078 bool has_function() const { return has_function_; }
4067 4079
4068 virtual Representation RequiredInputRepresentation(int index) { 4080 virtual Representation RequiredInputRepresentation(int index) {
4069 return Representation::Tagged(); 4081 return Representation::Tagged();
4070 } 4082 }
4083 virtual HType CalculateInferredType();
4071 4084
4072 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral) 4085 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral)
4073 4086
4074 private: 4087 private:
4075 Handle<FixedArray> constant_properties_; 4088 Handle<FixedArray> constant_properties_;
4076 bool fast_elements_; 4089 bool fast_elements_;
4077 bool has_function_; 4090 bool has_function_;
4078 }; 4091 };
4079 4092
4080 4093
4081 class HRegExpLiteral: public HMaterializedLiteral<1> { 4094 class HRegExpLiteral: public HMaterializedLiteral<1> {
4082 public: 4095 public:
4083 HRegExpLiteral(HValue* context, 4096 HRegExpLiteral(HValue* context,
4084 Handle<String> pattern, 4097 Handle<String> pattern,
4085 Handle<String> flags, 4098 Handle<String> flags,
4086 int literal_index) 4099 int literal_index)
4087 : HMaterializedLiteral<1>(literal_index, 0), 4100 : HMaterializedLiteral<1>(literal_index, 0),
4088 pattern_(pattern), 4101 pattern_(pattern),
4089 flags_(flags) { 4102 flags_(flags) {
4090 SetOperandAt(0, context); 4103 SetOperandAt(0, context);
4091 } 4104 }
4092 4105
4093 HValue* context() { return OperandAt(0); } 4106 HValue* context() { return OperandAt(0); }
4094 Handle<String> pattern() { return pattern_; } 4107 Handle<String> pattern() { return pattern_; }
4095 Handle<String> flags() { return flags_; } 4108 Handle<String> flags() { return flags_; }
4096 4109
4097 virtual Representation RequiredInputRepresentation(int index) { 4110 virtual Representation RequiredInputRepresentation(int index) {
4098 return Representation::Tagged(); 4111 return Representation::Tagged();
4099 } 4112 }
4113 virtual HType CalculateInferredType();
4100 4114
4101 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) 4115 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral)
4102 4116
4103 private: 4117 private:
4104 Handle<String> pattern_; 4118 Handle<String> pattern_;
4105 Handle<String> flags_; 4119 Handle<String> flags_;
4106 }; 4120 };
4107 4121
4108 4122
4109 class HFunctionLiteral: public HTemplateInstruction<1> { 4123 class HFunctionLiteral: public HTemplateInstruction<1> {
4110 public: 4124 public:
4111 HFunctionLiteral(HValue* context, 4125 HFunctionLiteral(HValue* context,
4112 Handle<SharedFunctionInfo> shared, 4126 Handle<SharedFunctionInfo> shared,
4113 bool pretenure) 4127 bool pretenure)
4114 : shared_info_(shared), pretenure_(pretenure) { 4128 : shared_info_(shared), pretenure_(pretenure) {
4115 SetOperandAt(0, context); 4129 SetOperandAt(0, context);
4116 set_representation(Representation::Tagged()); 4130 set_representation(Representation::Tagged());
4117 } 4131 }
4118 4132
4119 HValue* context() { return OperandAt(0); } 4133 HValue* context() { return OperandAt(0); }
4120 4134
4121 virtual Representation RequiredInputRepresentation(int index) { 4135 virtual Representation RequiredInputRepresentation(int index) {
4122 return Representation::Tagged(); 4136 return Representation::Tagged();
4123 } 4137 }
4138 virtual HType CalculateInferredType();
4124 4139
4125 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) 4140 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral)
4126 4141
4127 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 4142 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
4128 bool pretenure() const { return pretenure_; } 4143 bool pretenure() const { return pretenure_; }
4129 4144
4130 private: 4145 private:
4131 Handle<SharedFunctionInfo> shared_info_; 4146 Handle<SharedFunctionInfo> shared_info_;
4132 bool pretenure_; 4147 bool pretenure_;
4133 }; 4148 };
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
4233 4248
4234 DECLARE_CONCRETE_INSTRUCTION(In) 4249 DECLARE_CONCRETE_INSTRUCTION(In)
4235 }; 4250 };
4236 4251
4237 #undef DECLARE_INSTRUCTION 4252 #undef DECLARE_INSTRUCTION
4238 #undef DECLARE_CONCRETE_INSTRUCTION 4253 #undef DECLARE_CONCRETE_INSTRUCTION
4239 4254
4240 } } // namespace v8::internal 4255 } } // namespace v8::internal
4241 4256
4242 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 4257 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698