Simplify array element access in Hydrogen.

No change in functionality intended.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/26986004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17221 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f8f4e6c9
...@@ -1311,9 +1311,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache( ...@@ -1311,9 +1311,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache(
// Load the key. // Load the key.
HValue* key_index = Add<HShl>(hash, graph()->GetConstant1()); HValue* key_index = Add<HShl>(hash, graph()->GetConstant1());
HValue* key = AddFastElementAccess(number_string_cache, key_index, HValue* key = Add<HLoadKeyed>(number_string_cache, key_index,
NULL, NULL, FAST_ELEMENTS, false, static_cast<HValue*>(NULL),
ALLOW_RETURN_HOLE, STANDARD_STORE); FAST_ELEMENTS, ALLOW_RETURN_HOLE);
// Check if object == key. // Check if object == key.
IfBuilder if_objectiskey(this); IfBuilder if_objectiskey(this);
...@@ -1343,9 +1343,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache( ...@@ -1343,9 +1343,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache(
// Load the key. // Load the key.
HValue* key_index = Add<HShl>(hash, graph()->GetConstant1()); HValue* key_index = Add<HShl>(hash, graph()->GetConstant1());
HValue* key = AddFastElementAccess(number_string_cache, key_index, HValue* key = Add<HLoadKeyed>(number_string_cache, key_index,
NULL, NULL, FAST_ELEMENTS, false, static_cast<HValue*>(NULL),
ALLOW_RETURN_HOLE, STANDARD_STORE); FAST_ELEMENTS, ALLOW_RETURN_HOLE);
// Check if key is a heap number. // Check if key is a heap number.
IfBuilder if_keyisnumber(this); IfBuilder if_keyisnumber(this);
...@@ -1380,9 +1380,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache( ...@@ -1380,9 +1380,9 @@ HValue* HGraphBuilder::BuildLookupNumberStringCache(
// Load the value in case of cache hit. // Load the value in case of cache hit.
HValue* key_index = Pop(); HValue* key_index = Pop();
HValue* value_index = Add<HAdd>(key_index, graph()->GetConstant1()); HValue* value_index = Add<HAdd>(key_index, graph()->GetConstant1());
HValue* value = AddFastElementAccess(number_string_cache, value_index, HValue* value = Add<HLoadKeyed>(number_string_cache, value_index,
NULL, NULL, FAST_ELEMENTS, false, static_cast<HValue*>(NULL),
ALLOW_RETURN_HOLE, STANDARD_STORE); FAST_ELEMENTS, ALLOW_RETURN_HOLE);
AddIncrementCounter(isolate()->counters()->number_to_string_native()); AddIncrementCounter(isolate()->counters()->number_to_string_native());
if_found.CaptureContinuation(continuation); if_found.CaptureContinuation(continuation);
...@@ -1470,7 +1470,7 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( ...@@ -1470,7 +1470,7 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>( HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>(
key, graph()->GetConstant0(), Token::GTE); key, graph()->GetConstant0(), Token::GTE);
negative_checker.Then(); negative_checker.Then();
HInstruction* result = AddExternalArrayElementAccess( HInstruction* result = AddElementAccess(
external_elements, key, val, bounds_check, elements_kind, is_store); external_elements, key, val, bounds_check, elements_kind, is_store);
negative_checker.ElseDeopt("Negative key encountered"); negative_checker.ElseDeopt("Negative key encountered");
length_checker.End(); length_checker.End();
...@@ -1480,7 +1480,7 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( ...@@ -1480,7 +1480,7 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
checked_key = Add<HBoundsCheck>(key, length); checked_key = Add<HBoundsCheck>(key, length);
HLoadExternalArrayPointer* external_elements = HLoadExternalArrayPointer* external_elements =
Add<HLoadExternalArrayPointer>(elements); Add<HLoadExternalArrayPointer>(elements);
return AddExternalArrayElementAccess( return AddElementAccess(
external_elements, checked_key, val, external_elements, checked_key, val,
checked_object, elements_kind, is_store); checked_object, elements_kind, is_store);
} }
...@@ -1513,14 +1513,13 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( ...@@ -1513,14 +1513,13 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
elements_kind, length); elements_kind, length);
} else { } else {
HCheckMaps* check_cow_map = Add<HCheckMaps>( HCheckMaps* check_cow_map = Add<HCheckMaps>(
elements, isolate()->factory()->fixed_array_map(), elements, isolate()->factory()->fixed_array_map(), top_info());
top_info());
check_cow_map->ClearGVNFlag(kDependsOnElementsKind); check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
} }
} }
} }
return AddFastElementAccess(elements, checked_key, val, checked_object, return AddElementAccess(elements, checked_key, val, checked_object,
elements_kind, is_store, load_mode, store_mode); elements_kind, is_store, load_mode);
} }
...@@ -1610,85 +1609,31 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, ...@@ -1610,85 +1609,31 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
} }
HInstruction* HGraphBuilder::AddExternalArrayElementAccess( HInstruction* HGraphBuilder::AddElementAccess(
HValue* external_elements, HValue* elements,
HValue* checked_key, HValue* checked_key,
HValue* val, HValue* val,
HValue* dependency, HValue* dependency,
ElementsKind elements_kind, ElementsKind elements_kind,
bool is_store) { bool is_store,
LoadKeyedHoleMode load_mode) {
if (is_store) { if (is_store) {
ASSERT(val != NULL); ASSERT(val != NULL);
switch (elements_kind) { if (elements_kind == EXTERNAL_PIXEL_ELEMENTS) {
case EXTERNAL_PIXEL_ELEMENTS: { val = Add<HClampToUint8>(val);
val = Add<HClampToUint8>(val);
break;
}
case EXTERNAL_BYTE_ELEMENTS:
case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
case EXTERNAL_SHORT_ELEMENTS:
case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
case EXTERNAL_INT_ELEMENTS:
case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
break;
}
case EXTERNAL_FLOAT_ELEMENTS:
case EXTERNAL_DOUBLE_ELEMENTS:
break;
case FAST_SMI_ELEMENTS:
case FAST_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_SMI_ELEMENTS:
case FAST_HOLEY_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS:
case DICTIONARY_ELEMENTS:
case NON_STRICT_ARGUMENTS_ELEMENTS:
UNREACHABLE();
break;
} }
return Add<HStoreKeyed>(external_elements, checked_key, val, elements_kind); return Add<HStoreKeyed>(elements, checked_key, val, elements_kind);
} else {
ASSERT(val == NULL);
HLoadKeyed* load = Add<HLoadKeyed>(external_elements,
checked_key,
dependency,
elements_kind);
if (FLAG_opt_safe_uint32_operations &&
elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
graph()->RecordUint32Instruction(load);
}
return load;
} }
}
ASSERT(!is_store);
HInstruction* HGraphBuilder::AddFastElementAccess( ASSERT(val == NULL);
HValue* elements, HLoadKeyed* load = Add<HLoadKeyed>(
HValue* checked_key, elements, checked_key, dependency, elements_kind, load_mode);
HValue* val, if (FLAG_opt_safe_uint32_operations &&
HValue* load_dependency, elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) {
ElementsKind elements_kind, graph()->RecordUint32Instruction(load);
bool is_store,
LoadKeyedHoleMode load_mode,
KeyedAccessStoreMode store_mode) {
if (is_store) {
ASSERT(val != NULL);
switch (elements_kind) {
case FAST_SMI_ELEMENTS:
case FAST_HOLEY_SMI_ELEMENTS:
case FAST_ELEMENTS:
case FAST_HOLEY_ELEMENTS:
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS:
return Add<HStoreKeyed>(elements, checked_key, val, elements_kind);
default:
UNREACHABLE();
return NULL;
}
} }
// It's an element load (!is_store). return load;
return Add<HLoadKeyed>(
elements, checked_key, load_dependency, elements_kind, load_mode);
} }
...@@ -5139,8 +5084,7 @@ void HOptimizedGraphBuilder::BuildStore(Expression* expr, ...@@ -5139,8 +5084,7 @@ void HOptimizedGraphBuilder::BuildStore(Expression* expr,
HValue* key = environment()->ExpressionStackAt(1); HValue* key = environment()->ExpressionStackAt(1);
HValue* object = environment()->ExpressionStackAt(2); HValue* object = environment()->ExpressionStackAt(2);
bool has_side_effects = false; bool has_side_effects = false;
HandleKeyedElementAccess(object, key, value, expr, return_id, HandleKeyedElementAccess(object, key, value, expr, expr->position(),
expr->position(),
true, // is_store true, // is_store
&has_side_effects); &has_side_effects);
Drop(3); Drop(3);
...@@ -5689,7 +5633,6 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( ...@@ -5689,7 +5633,6 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess(
HValue* key, HValue* key,
HValue* val, HValue* val,
SmallMapList* maps, SmallMapList* maps,
BailoutId ast_id,
int position, int position,
bool is_store, bool is_store,
KeyedAccessStoreMode store_mode, KeyedAccessStoreMode store_mode,
...@@ -5821,7 +5764,6 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( ...@@ -5821,7 +5764,6 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess(
HValue* key, HValue* key,
HValue* val, HValue* val,
Expression* expr, Expression* expr,
BailoutId ast_id,
int position, int position,
bool is_store, bool is_store,
bool* has_side_effects) { bool* has_side_effects) {
...@@ -5844,7 +5786,7 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( ...@@ -5844,7 +5786,7 @@ HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess(
} }
} else if (types != NULL && !types->is_empty()) { } else if (types != NULL && !types->is_empty()) {
return HandlePolymorphicElementAccess( return HandlePolymorphicElementAccess(
obj, key, val, types, ast_id, position, is_store, obj, key, val, types, position, is_store,
expr->GetStoreMode(), has_side_effects); expr->GetStoreMode(), has_side_effects);
} else { } else {
if (is_store) { if (is_store) {
...@@ -6033,7 +5975,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, ...@@ -6033,7 +5975,7 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
bool has_side_effects = false; bool has_side_effects = false;
HValue* load = HandleKeyedElementAccess( HValue* load = HandleKeyedElementAccess(
obj, key, NULL, expr, ast_id, position, obj, key, NULL, expr, position,
false, // is_store false, // is_store
&has_side_effects); &has_side_effects);
if (has_side_effects) { if (has_side_effects) {
......
...@@ -1253,23 +1253,14 @@ class HGraphBuilder { ...@@ -1253,23 +1253,14 @@ class HGraphBuilder {
LoadKeyedHoleMode load_mode, LoadKeyedHoleMode load_mode,
KeyedAccessStoreMode store_mode); KeyedAccessStoreMode store_mode);
HInstruction* AddExternalArrayElementAccess( HInstruction* AddElementAccess(
HValue* external_elements,
HValue* checked_key,
HValue* val,
HValue* dependency,
ElementsKind elements_kind,
bool is_store);
HInstruction* AddFastElementAccess(
HValue* elements, HValue* elements,
HValue* checked_key, HValue* checked_key,
HValue* val, HValue* val,
HValue* dependency, HValue* dependency,
ElementsKind elements_kind, ElementsKind elements_kind,
bool is_store, bool is_store,
LoadKeyedHoleMode load_mode, LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);
KeyedAccessStoreMode store_mode);
HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access); HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value); HInstruction* BuildLoadStringLength(HValue* object, HValue* checked_value);
...@@ -2196,7 +2187,6 @@ class HOptimizedGraphBuilder V8_FINAL ...@@ -2196,7 +2187,6 @@ class HOptimizedGraphBuilder V8_FINAL
HValue* key, HValue* key,
HValue* val, HValue* val,
SmallMapList* maps, SmallMapList* maps,
BailoutId ast_id,
int position, int position,
bool is_store, bool is_store,
KeyedAccessStoreMode store_mode, KeyedAccessStoreMode store_mode,
...@@ -2206,7 +2196,6 @@ class HOptimizedGraphBuilder V8_FINAL ...@@ -2206,7 +2196,6 @@ class HOptimizedGraphBuilder V8_FINAL
HValue* key, HValue* key,
HValue* val, HValue* val,
Expression* expr, Expression* expr,
BailoutId ast_id,
int position, int position,
bool is_store, bool is_store,
bool* has_side_effects); bool* has_side_effects);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment