Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 23831925f3738c8b6abedf6e0a391a9097ff1ad3..1410fe595bcd67b59c14a9716cb0b388005e3992 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -3214,26 +3214,11 @@ void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { |
value = Pop(); |
HValue* key = Pop(); |
HValue* object = Pop(); |
- |
- if (expr->IsMonomorphic()) { |
- Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
- // An object has either fast elements or external array elements, but |
- // never both. Pixel array maps that are assigned to pixel array elements |
- // are always created with the fast elements flag cleared. |
- if (receiver_type->has_external_array_elements()) { |
- instr = BuildStoreKeyedSpecializedArrayElement(object, |
- key, |
- value, |
- expr); |
- } else if (receiver_type->has_fast_elements()) { |
- instr = BuildStoreKeyedFastElement(object, key, value, expr); |
- } |
- } |
- if (instr == NULL) { |
- instr = BuildStoreKeyedGeneric(object, key, value); |
- } |
+ instr = BuildStoreKeyed(object, |
Mads Ager (chromium)
2011/04/06 16:45:15
Looks like this will not fit on one line?
|
+ key, |
+ value, |
+ expr); |
} |
- |
Push(value); |
instr->set_position(expr->position()); |
AddInstruction(instr); |
@@ -3297,6 +3282,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
} else if (prop != NULL) { |
prop->RecordTypeFeedback(oracle()); |
+ expr->RecordTypeFeedback(oracle()); |
Mads Ager (chromium)
2011/04/06 16:45:15
Maybe move this to the only branch where it is nee
|
if (prop->key()->IsPropertyName()) { |
// Named property. |
@@ -3337,11 +3323,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
HValue* obj = environment()->ExpressionStackAt(1); |
HValue* key = environment()->ExpressionStackAt(0); |
- bool is_fast_elements = prop->IsMonomorphic() && |
- prop->GetMonomorphicReceiverType()->has_fast_elements(); |
- HInstruction* load = is_fast_elements |
- ? BuildLoadKeyedFastElement(obj, key, prop) |
- : BuildLoadKeyedGeneric(obj, key); |
+ HInstruction* load = BuildLoadKeyed(obj, key, prop); |
PushAndAdd(load); |
if (load->HasSideEffects()) AddSimulate(expr->CompoundLoadId()); |
@@ -3353,9 +3335,7 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
PushAndAdd(instr); |
if (instr->HasSideEffects()) AddSimulate(operation->id()); |
- HInstruction* store = is_fast_elements |
- ? BuildStoreKeyedFastElement(obj, key, instr, prop) |
- : BuildStoreKeyedGeneric(obj, key, instr); |
+ HInstruction* store = BuildStoreKeyed(obj, key, instr, expr); |
AddInstruction(store); |
// Drop the simulated receiver, key, and value. Return the value. |
Drop(3); |
@@ -3558,11 +3538,29 @@ HInstruction* HGraphBuilder::BuildLoadKeyedSpecializedArrayElement( |
HLoadKeyedSpecializedArrayElement* pixel_array_value = |
new HLoadKeyedSpecializedArrayElement(external_elements, |
key, |
- expr->GetExternalArrayType()); |
+ expr->external_array_type()); |
return pixel_array_value; |
} |
+HInstruction* HGraphBuilder::BuildLoadKeyed(HValue* obj, |
+ HValue* key, |
+ Property* prop) { |
+ if (prop->IsMonomorphic()) { |
+ Handle<Map> receiver_type(prop->GetMonomorphicReceiverType()); |
+ // An object has either fast elements or pixel array elements, but never |
+ // both. Pixel array maps that are assigned to pixel array elements are |
+ // always created with the fast elements flag cleared. |
+ if (receiver_type->has_external_array_elements()) { |
+ return BuildLoadKeyedSpecializedArrayElement(obj, key, prop); |
+ } else if (receiver_type->has_fast_elements()) { |
+ return BuildLoadKeyedFastElement(obj, key, prop); |
+ } |
+ } |
+ return BuildLoadKeyedGeneric(obj, key); |
+} |
+ |
+ |
HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, |
HValue* key, |
HValue* value) { |
@@ -3572,10 +3570,11 @@ HInstruction* HGraphBuilder::BuildStoreKeyedGeneric(HValue* object, |
} |
-HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, |
- HValue* key, |
- HValue* val, |
- Expression* expr) { |
+HInstruction* HGraphBuilder::BuildStoreKeyedFastElement( |
+ HValue* object, |
+ HValue* key, |
+ HValue* val, |
+ Expression* expr) { |
ASSERT(expr->IsMonomorphic()); |
AddInstruction(new HCheckNonSmi(object)); |
Handle<Map> map = expr->GetMonomorphicReceiverType(); |
@@ -3600,7 +3599,7 @@ HInstruction* HGraphBuilder::BuildStoreKeyedSpecializedArrayElement( |
HValue* object, |
HValue* key, |
HValue* val, |
- Assignment* expr) { |
+ Expression* expr) { |
ASSERT(expr->IsMonomorphic()); |
AddInstruction(new HCheckNonSmi(object)); |
Handle<Map> map = expr->GetMonomorphicReceiverType(); |
@@ -3614,11 +3613,32 @@ HInstruction* HGraphBuilder::BuildStoreKeyedSpecializedArrayElement( |
HLoadExternalArrayPointer* external_elements = |
new HLoadExternalArrayPointer(elements); |
AddInstruction(external_elements); |
- return new HStoreKeyedSpecializedArrayElement( |
- external_elements, |
- key, |
- val, |
- expr->GetExternalArrayType()); |
+ return new HStoreKeyedSpecializedArrayElement(external_elements, |
+ key, |
+ val, |
+ expr->external_array_type()); |
+} |
+ |
+ |
+HInstruction* HGraphBuilder::BuildStoreKeyed(HValue* object, |
+ HValue* key, |
+ HValue* value, |
+ Expression* expr) { |
+ if (expr->IsMonomorphic()) { |
+ Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
+ // An object has either fast elements or external array elements, but |
+ // never both. Pixel array maps that are assigned to pixel array elements |
+ // are always created with the fast elements flag cleared. |
+ if (receiver_type->has_external_array_elements()) { |
+ return BuildStoreKeyedSpecializedArrayElement(object, |
+ key, |
+ value, |
+ expr); |
+ } else if (receiver_type->has_fast_elements()) { |
+ return BuildStoreKeyedFastElement(object, key, value, expr); |
+ } |
+ } |
+ return BuildStoreKeyedGeneric(object, key, value); |
} |
@@ -3706,21 +3726,7 @@ void HGraphBuilder::VisitProperty(Property* expr) { |
HValue* key = Pop(); |
HValue* obj = Pop(); |
- |
- if (expr->IsMonomorphic()) { |
- Handle<Map> receiver_type(expr->GetMonomorphicReceiverType()); |
- // An object has either fast elements or pixel array elements, but never |
- // both. Pixel array maps that are assigned to pixel array elements are |
- // always created with the fast elements flag cleared. |
- if (receiver_type->has_external_array_elements()) { |
- instr = BuildLoadKeyedSpecializedArrayElement(obj, key, expr); |
- } else if (receiver_type->has_fast_elements()) { |
- instr = BuildLoadKeyedFastElement(obj, key, expr); |
- } |
- } |
- if (instr == NULL) { |
- instr = BuildLoadKeyedGeneric(obj, key); |
- } |
+ instr = BuildLoadKeyed(obj, key, expr); |
} |
instr->set_position(expr->position()); |
ast_context()->ReturnInstruction(instr, expr->id()); |
@@ -4577,7 +4583,8 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { |
ast_context()->ReturnValue(expr->is_postfix() ? before : after); |
} else if (prop != NULL) { |
- prop->RecordTypeFeedback(oracle()); |
+ prop->RecordTypeFeedback(oracle()); |
+ expr->RecordTypeFeedback(oracle()); |
Mads Ager (chromium)
2011/04/06 16:45:15
Move to where it is needed?
|
if (prop->key()->IsPropertyName()) { |
// Named property. |
@@ -4633,12 +4640,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { |
HValue* obj = environment()->ExpressionStackAt(1); |
HValue* key = environment()->ExpressionStackAt(0); |
- bool is_fast_elements = prop->IsMonomorphic() && |
- prop->GetMonomorphicReceiverType()->has_fast_elements(); |
- |
- HInstruction* load = is_fast_elements |
- ? BuildLoadKeyedFastElement(obj, key, prop) |
- : BuildLoadKeyedGeneric(obj, key); |
+ HInstruction* load = BuildLoadKeyed(obj, key, prop); |
PushAndAdd(load); |
if (load->HasSideEffects()) AddSimulate(increment->id()); |
@@ -4648,9 +4650,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { |
HInstruction* after = BuildIncrement(before, inc); |
AddInstruction(after); |
- HInstruction* store = is_fast_elements |
- ? BuildStoreKeyedFastElement(obj, key, after, prop) |
- : BuildStoreKeyedGeneric(obj, key, after); |
+ HInstruction* store = BuildStoreKeyed(obj, key, after, expr); |
AddInstruction(store); |
// Drop the key from the bailout environment. Overwrite the receiver |