Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Version 4.8.271.9 (cherry-pick)
Browse files Browse the repository at this point in the history
Merged 086d459

[crankshaft] Loads and stores to typed arrays have to reference the backing store holder

BUG=v8:1827
LOG=N
[email protected]

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

Cr-Commit-Position: refs/branch-heads/4.8@{#12}
Cr-Branched-From: 10449d4-refs/heads/4.8.271@{#1}
Cr-Branched-From: 2ebd5fc-refs/heads/master@{#31941}
  • Loading branch information
jeisinger committed Dec 9, 2015
1 parent 561ecce commit 9bd13de
Show file tree
Hide file tree
Showing 23 changed files with 328 additions and 199 deletions.
2 changes: 1 addition & 1 deletion include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 8
#define V8_BUILD_NUMBER 271
#define V8_PATCH_LEVEL 8
#define V8_PATCH_LEVEL 9

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
49 changes: 26 additions & 23 deletions src/code-stubs-hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
info()->MarkMustNotHaveEagerFrame();

HInstruction* allocation_site = Add<HLoadKeyed>(
GetParameter(0), GetParameter(1), nullptr, FAST_ELEMENTS,
GetParameter(0), GetParameter(1), nullptr, nullptr, FAST_ELEMENTS,
NEVER_RETURN_HOLE, LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag);
IfBuilder checker(this);
checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site,
Expand Down Expand Up @@ -506,7 +506,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
HValue* undefined = graph()->GetConstantUndefined();

HInstruction* allocation_site = Add<HLoadKeyed>(
GetParameter(0), GetParameter(1), nullptr, FAST_ELEMENTS,
GetParameter(0), GetParameter(1), nullptr, nullptr, FAST_ELEMENTS,
NEVER_RETURN_HOLE, LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag);

IfBuilder checker(this);
Expand Down Expand Up @@ -636,7 +636,7 @@ HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {

HInstruction* feedback_vector = GetParameter(0);
HInstruction* slot = GetParameter(1);
Add<HStoreKeyed>(feedback_vector, slot, object, FAST_ELEMENTS,
Add<HStoreKeyed>(feedback_vector, slot, object, nullptr, FAST_ELEMENTS,
INITIALIZING_STORE);
return feedback_vector;
}
Expand Down Expand Up @@ -668,7 +668,7 @@ HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() {
HInstruction* feedback_vector =
GetParameter(CreateWeakCellDescriptor::kVectorIndex);
HInstruction* slot = GetParameter(CreateWeakCellDescriptor::kSlotIndex);
Add<HStoreKeyed>(feedback_vector, slot, object, FAST_ELEMENTS,
Add<HStoreKeyed>(feedback_vector, slot, object, nullptr, FAST_ELEMENTS,
INITIALIZING_STORE);
return graph()->GetConstant0();
}
Expand Down Expand Up @@ -824,8 +824,8 @@ HValue* CodeStubGraphBuilderBase::UnmappedCase(HValue* elements, HValue* key,
HValue* value) {
HValue* result = NULL;
HInstruction* backing_store =
Add<HLoadKeyed>(elements, graph()->GetConstant1(), nullptr, FAST_ELEMENTS,
ALLOW_RETURN_HOLE);
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());
Expand All @@ -835,10 +835,10 @@ HValue* CodeStubGraphBuilderBase::UnmappedCase(HValue* elements, HValue* key,
in_unmapped_range.Then();
{
if (value == NULL) {
result = Add<HLoadKeyed>(backing_store, key, nullptr, FAST_HOLEY_ELEMENTS,
NEVER_RETURN_HOLE);
result = Add<HLoadKeyed>(backing_store, key, nullptr, nullptr,
FAST_HOLEY_ELEMENTS, NEVER_RETURN_HOLE);
} else {
Add<HStoreKeyed>(backing_store, key, value, FAST_HOLEY_ELEMENTS);
Add<HStoreKeyed>(backing_store, key, value, nullptr, FAST_HOLEY_ELEMENTS);
}
}
in_unmapped_range.ElseDeopt(Deoptimizer::kOutsideOfRange);
Expand Down Expand Up @@ -895,8 +895,9 @@ HValue* CodeStubGraphBuilderBase::EmitKeyedSloppyArguments(HValue* receiver,
in_range.Then();
{
HValue* index = AddUncasted<HAdd>(key, constant_two);
HInstruction* mapped_index = Add<HLoadKeyed>(
elements, index, nullptr, FAST_HOLEY_ELEMENTS, ALLOW_RETURN_HOLE);
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,
Expand All @@ -907,15 +908,17 @@ HValue* CodeStubGraphBuilderBase::EmitKeyedSloppyArguments(HValue* receiver,
// 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, FAST_ELEMENTS);
nullptr, nullptr, FAST_ELEMENTS);
STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize);
if (is_load) {
HValue* result = Add<HLoadKeyed>(the_context, mapped_index, nullptr,
FAST_ELEMENTS, ALLOW_RETURN_HOLE);
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, FAST_ELEMENTS);
Add<HStoreKeyed>(the_context, mapped_index, value, nullptr,
FAST_ELEMENTS);
environment()->Push(value);
}
}
Expand Down Expand Up @@ -1274,7 +1277,7 @@ HValue* CodeStubGraphBuilderBase::BuildArrayNArgumentsConstructor(
HInstruction* argument = Add<HAccessArgumentsAt>(
argument_elements, checked_length, key);

Add<HStoreKeyed>(elements, key, argument, kind);
Add<HStoreKeyed>(elements, key, argument, nullptr, kind);
builder.EndBody();
return new_object;
}
Expand Down Expand Up @@ -1905,8 +1908,8 @@ HInstruction* CodeStubGraphBuilderBase::LoadFromOptimizedCodeMap(
HValue* field_offset_value = Add<HConstant>(field_offset);
field_slot = AddUncasted<HAdd>(iterator, field_offset_value);
}
HInstruction* field_entry =
Add<HLoadKeyed>(optimized_map, field_slot, nullptr, FAST_ELEMENTS);
HInstruction* field_entry = Add<HLoadKeyed>(optimized_map, field_slot,
nullptr, nullptr, FAST_ELEMENTS);
return field_entry;
}

Expand Down Expand Up @@ -2326,13 +2329,13 @@ HValue* CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildCodeStub() {
Add<HConstant>(probe_base + KeyedLookupCache::kKeyIndex));
key_index->ClearFlag(HValue::kCanOverflow);
HValue* map_to_check =
Add<HLoadKeyed>(cache_keys, map_index, nullptr, FAST_ELEMENTS,
NEVER_RETURN_HOLE, 0);
Add<HLoadKeyed>(cache_keys, map_index, nullptr, nullptr,
FAST_ELEMENTS, NEVER_RETURN_HOLE, 0);
lookup_if->If<HCompareObjectEqAndBranch>(map_to_check, map);
lookup_if->And();
HValue* key_to_check =
Add<HLoadKeyed>(cache_keys, key_index, nullptr, FAST_ELEMENTS,
NEVER_RETURN_HOLE, 0);
Add<HLoadKeyed>(cache_keys, key_index, nullptr, nullptr,
FAST_ELEMENTS, NEVER_RETURN_HOLE, 0);
lookup_if->If<HCompareObjectEqAndBranch>(key_to_check, key);
lookup_if->Then();
{
Expand All @@ -2343,7 +2346,7 @@ HValue* CodeStubGraphBuilder<KeyedLoadGenericStub>::BuildCodeStub() {
HValue* index = AddUncasted<HAdd>(hash, Add<HConstant>(probe));
index->ClearFlag(HValue::kCanOverflow);
HValue* property_index =
Add<HLoadKeyed>(cache_field_offsets, index, nullptr,
Add<HLoadKeyed>(cache_field_offsets, index, nullptr, cache_keys,
INT32_ELEMENTS, NEVER_RETURN_HOLE, 0);
Push(property_index);
}
Expand Down
11 changes: 7 additions & 4 deletions src/crankshaft/arm/lithium-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2205,15 +2205,17 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
DCHECK(instr->representation().IsSmiOrTagged());
obj = UseRegisterAtStart(instr->elements());
}
result = DefineAsRegister(new(zone()) LLoadKeyed(obj, key));
result = DefineAsRegister(new (zone()) LLoadKeyed(obj, key, nullptr));
} else {
DCHECK(
(instr->representation().IsInteger32() &&
!IsDoubleOrFloatElementsKind(elements_kind)) ||
(instr->representation().IsDouble() &&
IsDoubleOrFloatElementsKind(elements_kind)));
LOperand* backing_store = UseRegister(instr->elements());
result = DefineAsRegister(new(zone()) LLoadKeyed(backing_store, key));
LOperand* backing_store_owner = UseAny(instr->backing_store_owner());
result = DefineAsRegister(
new (zone()) LLoadKeyed(backing_store, key, backing_store_owner));
}

bool needs_environment;
Expand Down Expand Up @@ -2278,7 +2280,7 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
}
}

return new(zone()) LStoreKeyed(object, key, val);
return new (zone()) LStoreKeyed(object, key, val, nullptr);
}

DCHECK(
Expand All @@ -2290,7 +2292,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
LOperand* val = UseRegister(instr->value());
LOperand* key = UseRegisterOrConstantAtStart(instr->key());
LOperand* backing_store = UseRegister(instr->elements());
return new(zone()) LStoreKeyed(backing_store, key, val);
LOperand* backing_store_owner = UseAny(instr->backing_store_owner());
return new (zone()) LStoreKeyed(backing_store, key, val, backing_store_owner);
}


Expand Down
13 changes: 9 additions & 4 deletions src/crankshaft/arm/lithium-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1605,15 +1605,17 @@ class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
};


class LLoadKeyed final : public LTemplateInstruction<1, 2, 0> {
class LLoadKeyed final : public LTemplateInstruction<1, 3, 0> {
public:
LLoadKeyed(LOperand* elements, LOperand* key) {
LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
inputs_[0] = elements;
inputs_[1] = key;
inputs_[2] = backing_store_owner;
}

LOperand* elements() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* backing_store_owner() { return inputs_[2]; }
ElementsKind elements_kind() const {
return hydrogen()->elements_kind();
}
Expand Down Expand Up @@ -2171,12 +2173,14 @@ class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
};


class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> {
public:
LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
LOperand* backing_store_owner) {
inputs_[0] = object;
inputs_[1] = key;
inputs_[2] = value;
inputs_[3] = backing_store_owner;
}

bool is_fixed_typed_array() const {
Expand All @@ -2185,6 +2189,7 @@ class LStoreKeyed final : public LTemplateInstruction<0, 3, 0> {
LOperand* elements() { return inputs_[0]; }
LOperand* key() { return inputs_[1]; }
LOperand* value() { return inputs_[2]; }
LOperand* backing_store_owner() { return inputs_[3]; }
ElementsKind elements_kind() const {
return hydrogen()->elements_kind();
}
Expand Down
9 changes: 6 additions & 3 deletions src/crankshaft/arm64/lithium-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1714,8 +1714,9 @@ LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
IsDoubleOrFloatElementsKind(instr->elements_kind())));

LOperand* temp = instr->key()->IsConstant() ? NULL : TempRegister();
LInstruction* result = DefineAsRegister(
new(zone()) LLoadKeyedExternal(elements, key, temp));
LOperand* backing_store_owner = UseAny(instr->backing_store_owner());
LInstruction* result = DefineAsRegister(new (zone()) LLoadKeyedExternal(
elements, key, backing_store_owner, temp));
if (elements_kind == UINT32_ELEMENTS &&
!instr->CheckFlag(HInstruction::kUint32)) {
result = AssignEnvironment(result);
Expand Down Expand Up @@ -2341,7 +2342,9 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
(instr->value()->representation().IsDouble() &&
IsDoubleOrFloatElementsKind(instr->elements_kind())));
DCHECK(instr->elements()->representation().IsExternal());
return new(zone()) LStoreKeyedExternal(elements, key, val, temp);
LOperand* backing_store_owner = UseAny(instr->backing_store_owner());
return new (zone())
LStoreKeyedExternal(elements, key, val, backing_store_owner, temp);

} else if (instr->value()->representation().IsDouble()) {
DCHECK(instr->elements()->representation().IsTagged());
Expand Down
42 changes: 24 additions & 18 deletions src/crankshaft/arm64/lithium-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1714,16 +1714,18 @@ class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
};


template<int T>
class LLoadKeyed : public LTemplateInstruction<1, 2, T> {
template <int T>
class LLoadKeyed : public LTemplateInstruction<1, 3, T> {
public:
LLoadKeyed(LOperand* elements, LOperand* key) {
LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
this->inputs_[0] = elements;
this->inputs_[1] = key;
this->inputs_[2] = backing_store_owner;
}

LOperand* elements() { return this->inputs_[0]; }
LOperand* key() { return this->inputs_[1]; }
LOperand* backing_store_owner() { return this->inputs_[2]; }
ElementsKind elements_kind() const {
return this->hydrogen()->elements_kind();
}
Expand Down Expand Up @@ -1756,8 +1758,9 @@ class LLoadKeyed : public LTemplateInstruction<1, 2, T> {

class LLoadKeyedExternal: public LLoadKeyed<1> {
public:
LLoadKeyedExternal(LOperand* elements, LOperand* key, LOperand* temp) :
LLoadKeyed<1>(elements, key) {
LLoadKeyedExternal(LOperand* elements, LOperand* key,
LOperand* backing_store_owner, LOperand* temp)
: LLoadKeyed<1>(elements, key, backing_store_owner) {
temps_[0] = temp;
}

Expand All @@ -1769,8 +1772,8 @@ class LLoadKeyedExternal: public LLoadKeyed<1> {

class LLoadKeyedFixed: public LLoadKeyed<1> {
public:
LLoadKeyedFixed(LOperand* elements, LOperand* key, LOperand* temp) :
LLoadKeyed<1>(elements, key) {
LLoadKeyedFixed(LOperand* elements, LOperand* key, LOperand* temp)
: LLoadKeyed<1>(elements, key, nullptr) {
temps_[0] = temp;
}

Expand All @@ -1782,8 +1785,8 @@ class LLoadKeyedFixed: public LLoadKeyed<1> {

class LLoadKeyedFixedDouble: public LLoadKeyed<1> {
public:
LLoadKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* temp) :
LLoadKeyed<1>(elements, key) {
LLoadKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* temp)
: LLoadKeyed<1>(elements, key, nullptr) {
temps_[0] = temp;
}

Expand Down Expand Up @@ -2417,13 +2420,15 @@ class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
};


template<int T>
class LStoreKeyed : public LTemplateInstruction<0, 3, T> {
template <int T>
class LStoreKeyed : public LTemplateInstruction<0, 4, T> {
public:
LStoreKeyed(LOperand* elements, LOperand* key, LOperand* value) {
LStoreKeyed(LOperand* elements, LOperand* key, LOperand* value,
LOperand* backing_store_owner) {
this->inputs_[0] = elements;
this->inputs_[1] = key;
this->inputs_[2] = value;
this->inputs_[3] = backing_store_owner;
}

bool is_external() const { return this->hydrogen()->is_external(); }
Expand All @@ -2436,6 +2441,7 @@ class LStoreKeyed : public LTemplateInstruction<0, 3, T> {
LOperand* elements() { return this->inputs_[0]; }
LOperand* key() { return this->inputs_[1]; }
LOperand* value() { return this->inputs_[2]; }
LOperand* backing_store_owner() { return this->inputs_[3]; }
ElementsKind elements_kind() const {
return this->hydrogen()->elements_kind();
}
Expand Down Expand Up @@ -2475,8 +2481,8 @@ class LStoreKeyed : public LTemplateInstruction<0, 3, T> {
class LStoreKeyedExternal final : public LStoreKeyed<1> {
public:
LStoreKeyedExternal(LOperand* elements, LOperand* key, LOperand* value,
LOperand* temp) :
LStoreKeyed<1>(elements, key, value) {
LOperand* backing_store_owner, LOperand* temp)
: LStoreKeyed<1>(elements, key, value, backing_store_owner) {
temps_[0] = temp;
}

Expand All @@ -2489,8 +2495,8 @@ class LStoreKeyedExternal final : public LStoreKeyed<1> {
class LStoreKeyedFixed final : public LStoreKeyed<1> {
public:
LStoreKeyedFixed(LOperand* elements, LOperand* key, LOperand* value,
LOperand* temp) :
LStoreKeyed<1>(elements, key, value) {
LOperand* temp)
: LStoreKeyed<1>(elements, key, value, nullptr) {
temps_[0] = temp;
}

Expand All @@ -2503,8 +2509,8 @@ class LStoreKeyedFixed final : public LStoreKeyed<1> {
class LStoreKeyedFixedDouble final : public LStoreKeyed<1> {
public:
LStoreKeyedFixedDouble(LOperand* elements, LOperand* key, LOperand* value,
LOperand* temp) :
LStoreKeyed<1>(elements, key, value) {
LOperand* temp)
: LStoreKeyed<1>(elements, key, value, nullptr) {
temps_[0] = temp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/crankshaft/hydrogen-instructions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3546,7 +3546,7 @@ HValue* HLoadKeyedGeneric::Canonicalize() {
HInstruction* index = HLoadKeyed::New(
block()->graph()->isolate(), block()->graph()->zone(),
block()->graph()->GetInvalidContext(), index_cache, key_load->key(),
key_load->key(), key_load->elements_kind());
key_load->key(), nullptr, key_load->elements_kind());
map_check->InsertBefore(this);
index->InsertBefore(this);
return Prepend(new(block()->zone()) HLoadFieldByIndex(
Expand Down
Loading

0 comments on commit 9bd13de

Please sign in to comment.