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

Unified Diff: src/code-stubs-hydrogen.cc

Issue 2327103002: [stubs] Port KeyedLoadSloppyArgumentsStub and KeyedStoreSloppyArgumentsStub to TurboFan. (Closed)
Patch Set: Addressing comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index 57402362e861ff152d74dd0dd931b80ea7ab4d12..d52c4aeeb15a120a944d90264aa2dbfa7aee1ae6 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -84,10 +84,6 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
HValue* BuildPushElement(HValue* object, HValue* argc,
HValue* argument_elements, ElementsKind kind);
- HValue* UnmappedCase(HValue* elements, HValue* key, HValue* value);
- HValue* EmitKeyedSloppyArguments(HValue* receiver, HValue* key,
- HValue* value);
-
HValue* BuildToString(HValue* input, bool convert);
HValue* BuildToPrimitive(HValue* input, HValue* input_map);
@@ -905,155 +901,6 @@ HValue* CodeStubGraphBuilder<LoadConstantStub>::BuildCodeStub() {
Handle<Code> LoadConstantStub::GenerateCode() { return DoGenerateCode(this); }
-HValue* CodeStubGraphBuilderBase::UnmappedCase(HValue* elements, HValue* key,
- HValue* value) {
- HValue* result = NULL;
- HInstruction* backing_store =
- Add<HLoadKeyed>(elements, graph()->GetConstant1(), nullptr, nullptr,
- FAST_ELEMENTS, ALLOW_RETURN_HOLE);
- Add<HCheckMaps>(backing_store, isolate()->factory()->fixed_array_map());
- HValue* backing_store_length = Add<HLoadNamedField>(
- backing_store, nullptr, HObjectAccess::ForFixedArrayLength());
- IfBuilder in_unmapped_range(this);
- in_unmapped_range.If<HCompareNumericAndBranch>(key, backing_store_length,
- Token::LT);
- in_unmapped_range.Then();
- {
- if (value == NULL) {
- result = Add<HLoadKeyed>(backing_store, key, nullptr, nullptr,
- FAST_HOLEY_ELEMENTS, NEVER_RETURN_HOLE);
- } else {
- Add<HStoreKeyed>(backing_store, key, value, nullptr, FAST_HOLEY_ELEMENTS);
- }
- }
- in_unmapped_range.ElseDeopt(DeoptimizeReason::kOutsideOfRange);
- in_unmapped_range.End();
- return result;
-}
-
-
-HValue* CodeStubGraphBuilderBase::EmitKeyedSloppyArguments(HValue* receiver,
- HValue* key,
- HValue* value) {
- // Mapped arguments are actual arguments. Unmapped arguments are values added
- // to the arguments object after it was created for the call. Mapped arguments
- // are stored in the context at indexes given by elements[key + 2]. Unmapped
- // arguments are stored as regular indexed properties in the arguments array,
- // held at elements[1]. See NewSloppyArguments() in runtime.cc for a detailed
- // look at argument object construction.
- //
- // The sloppy arguments elements array has a special format:
- //
- // 0: context
- // 1: unmapped arguments array
- // 2: mapped_index0,
- // 3: mapped_index1,
- // ...
- //
- // length is 2 + min(number_of_actual_arguments, number_of_formal_arguments).
- // If key + 2 >= elements.length then attempt to look in the unmapped
- // arguments array (given by elements[1]) and return the value at key, missing
- // to the runtime if the unmapped arguments array is not a fixed array or if
- // key >= unmapped_arguments_array.length.
- //
- // Otherwise, t = elements[key + 2]. If t is the hole, then look up the value
- // in the unmapped arguments array, as described above. Otherwise, t is a Smi
- // index into the context array given at elements[0]. Return the value at
- // context[t].
-
- bool is_load = value == NULL;
-
- key = AddUncasted<HForceRepresentation>(key, Representation::Smi());
- IfBuilder positive_smi(this);
- positive_smi.If<HCompareNumericAndBranch>(key, graph()->GetConstant0(),
- Token::LT);
- positive_smi.ThenDeopt(DeoptimizeReason::kKeyIsNegative);
- positive_smi.End();
-
- HValue* constant_two = Add<HConstant>(2);
- HValue* elements = AddLoadElements(receiver, nullptr);
- HValue* elements_length = Add<HLoadNamedField>(
- elements, nullptr, HObjectAccess::ForFixedArrayLength());
- HValue* adjusted_length = AddUncasted<HSub>(elements_length, constant_two);
- IfBuilder in_range(this);
- in_range.If<HCompareNumericAndBranch>(key, adjusted_length, Token::LT);
- in_range.Then();
- {
- HValue* index = AddUncasted<HAdd>(key, constant_two);
- HInstruction* mapped_index =
- Add<HLoadKeyed>(elements, index, nullptr, nullptr, FAST_HOLEY_ELEMENTS,
- ALLOW_RETURN_HOLE);
-
- IfBuilder is_valid(this);
- is_valid.IfNot<HCompareObjectEqAndBranch>(mapped_index,
- graph()->GetConstantHole());
- is_valid.Then();
- {
- // TODO(mvstanton): I'd like to assert from this point, that if the
- // mapped_index is not the hole that it is indeed, a smi. An unnecessary
- // smi check is being emitted.
- HValue* the_context = Add<HLoadKeyed>(elements, graph()->GetConstant0(),
- nullptr, nullptr, FAST_ELEMENTS);
- STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize);
- if (is_load) {
- HValue* result =
- Add<HLoadKeyed>(the_context, mapped_index, nullptr, nullptr,
- FAST_ELEMENTS, ALLOW_RETURN_HOLE);
- environment()->Push(result);
- } else {
- DCHECK(value != NULL);
- Add<HStoreKeyed>(the_context, mapped_index, value, nullptr,
- FAST_ELEMENTS);
- environment()->Push(value);
- }
- }
- is_valid.Else();
- {
- HValue* result = UnmappedCase(elements, key, value);
- environment()->Push(is_load ? result : value);
- }
- is_valid.End();
- }
- in_range.Else();
- {
- HValue* result = UnmappedCase(elements, key, value);
- environment()->Push(is_load ? result : value);
- }
- in_range.End();
-
- return environment()->Pop();
-}
-
-
-template <>
-HValue* CodeStubGraphBuilder<KeyedLoadSloppyArgumentsStub>::BuildCodeStub() {
- HValue* receiver = GetParameter(Descriptor::kReceiver);
- HValue* key = GetParameter(Descriptor::kName);
-
- return EmitKeyedSloppyArguments(receiver, key, NULL);
-}
-
-
-Handle<Code> KeyedLoadSloppyArgumentsStub::GenerateCode() {
- return DoGenerateCode(this);
-}
-
-
-template <>
-HValue* CodeStubGraphBuilder<KeyedStoreSloppyArgumentsStub>::BuildCodeStub() {
- HValue* receiver = GetParameter(Descriptor::kReceiver);
- HValue* key = GetParameter(Descriptor::kName);
- HValue* value = GetParameter(Descriptor::kValue);
-
- return EmitKeyedSloppyArguments(receiver, key, value);
-}
-
-
-Handle<Code> KeyedStoreSloppyArgumentsStub::GenerateCode() {
- return DoGenerateCode(this);
-}
-
-
void CodeStubGraphBuilderBase::BuildStoreNamedField(
HValue* object, HValue* value, FieldIndex index,
Representation representation, bool transition_to_field) {
« no previous file with comments | « src/code-stubs.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698