Commit a54d7acb authored by ishell's avatar ishell Committed by Commit bot

[stubs] Enable graph verification for builtins.

... and fix the inconsistencies.

BUG=

Review-Url: https://codereview.chromium.org/2573573004
Cr-Commit-Position: refs/heads/master@{#41690}
parent cc47e27a
...@@ -225,9 +225,7 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) { ...@@ -225,9 +225,7 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) {
// to figure out whether the length property is still writable. // to figure out whether the length property is still writable.
assembler.Comment( assembler.Comment(
"Disallow pushing onto arrays in dictionary named property mode"); "Disallow pushing onto arrays in dictionary named property mode");
Node* bit_field3 = assembler.LoadMapBitField3(map); assembler.GotoIf(assembler.IsDictionaryMap(map), &runtime);
assembler.GotoIf(assembler.IsSetWord32<Map::DictionaryMap>(bit_field3),
&runtime);
// Check whether the length property is writable. The length property is the // Check whether the length property is writable. The length property is the
// only default named property on arrays. It's nonconfigurable, hence is // only default named property on arrays. It's nonconfigurable, hence is
...@@ -237,15 +235,15 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) { ...@@ -237,15 +235,15 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) {
descriptors, DescriptorArray::ToDetailsIndex(0)); descriptors, DescriptorArray::ToDetailsIndex(0));
mask = READ_ONLY << PropertyDetails::AttributesField::kShift; mask = READ_ONLY << PropertyDetails::AttributesField::kShift;
Node* mask_node = assembler.SmiConstant(mask); Node* mask_node = assembler.SmiConstant(mask);
test = assembler.WordAnd(details, mask_node); test = assembler.SmiAnd(details, mask_node);
assembler.GotoIf(assembler.WordEqual(test, mask_node), &runtime); assembler.GotoIf(assembler.WordEqual(test, mask_node), &runtime);
arg_index.Bind(assembler.IntPtrConstant(0)); arg_index.Bind(assembler.IntPtrConstant(0));
kind = assembler.DecodeWord32<Map::ElementsKindBits>(bit_field2); kind = assembler.DecodeWord32<Map::ElementsKindBits>(bit_field2);
assembler.GotoIf( assembler.GotoIf(
assembler.IntPtrGreaterThan( assembler.Int32GreaterThan(
kind, assembler.IntPtrConstant(FAST_HOLEY_SMI_ELEMENTS)), kind, assembler.Int32Constant(FAST_HOLEY_SMI_ELEMENTS)),
&object_push_pre); &object_push_pre);
Node* new_length = assembler.BuildAppendJSArray( Node* new_length = assembler.BuildAppendJSArray(
...@@ -273,8 +271,8 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) { ...@@ -273,8 +271,8 @@ void Builtins::Generate_FastArrayPush(compiler::CodeAssemblerState* state) {
assembler.Bind(&object_push_pre); assembler.Bind(&object_push_pre);
{ {
assembler.Branch(assembler.IntPtrGreaterThan( assembler.Branch(assembler.Int32GreaterThan(
kind, assembler.IntPtrConstant(FAST_HOLEY_ELEMENTS)), kind, assembler.Int32Constant(FAST_HOLEY_ELEMENTS)),
&double_push, &object_push); &double_push, &object_push);
} }
...@@ -2202,7 +2200,7 @@ void Builtins::Generate_ArrayIndexOf(compiler::CodeAssemblerState* state) { ...@@ -2202,7 +2200,7 @@ void Builtins::Generate_ArrayIndexOf(compiler::CodeAssemblerState* state) {
} }
assembler.Bind(&return_found); assembler.Bind(&return_found);
assembler.Return(assembler.ChangeInt32ToTagged(index_var.value())); assembler.Return(assembler.SmiTag(index_var.value()));
assembler.Bind(&return_not_found); assembler.Bind(&return_not_found);
assembler.Return(assembler.NumberConstant(-1)); assembler.Return(assembler.NumberConstant(-1));
...@@ -2339,10 +2337,9 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2339,10 +2337,9 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
assembler.GotoUnless(assembler.SmiBelow(index, length), &set_done); assembler.GotoUnless(assembler.SmiBelow(index, length), &set_done);
Node* one = assembler.SmiConstant(Smi::FromInt(1)); Node* one = assembler.SmiConstant(Smi::FromInt(1));
assembler.StoreObjectFieldNoWriteBarrier( assembler.StoreObjectFieldNoWriteBarrier(iterator,
iterator, JSArrayIterator::kNextIndexOffset, JSArrayIterator::kNextIndexOffset,
assembler.IntPtrAdd(assembler.BitcastTaggedToWord(index), assembler.SmiAdd(index, one));
assembler.BitcastTaggedToWord(one)));
var_done.Bind(assembler.FalseConstant()); var_done.Bind(assembler.FalseConstant());
Node* elements = assembler.LoadElements(array); Node* elements = assembler.LoadElements(array);
...@@ -2566,19 +2563,20 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2566,19 +2563,20 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
assembler.GotoUnless(assembler.SmiBelow(index, length), &set_done); assembler.GotoUnless(assembler.SmiBelow(index, length), &set_done);
Node* one = assembler.SmiConstant(Smi::FromInt(1)); Node* one = assembler.SmiConstant(1);
assembler.StoreObjectFieldNoWriteBarrier( assembler.StoreObjectFieldNoWriteBarrier(
iterator, JSArrayIterator::kNextIndexOffset, iterator, JSArrayIterator::kNextIndexOffset,
assembler.IntPtrAdd(assembler.BitcastTaggedToWord(index), assembler.SmiAdd(index, one));
assembler.BitcastTaggedToWord(one)));
var_done.Bind(assembler.FalseConstant()); var_done.Bind(assembler.FalseConstant());
Node* elements = assembler.LoadElements(array); Node* elements = assembler.LoadElements(array);
Node* base_ptr = assembler.LoadObjectField( Node* base_ptr = assembler.LoadObjectField(
elements, FixedTypedArrayBase::kBasePointerOffset); elements, FixedTypedArrayBase::kBasePointerOffset);
Node* external_ptr = assembler.LoadObjectField( Node* external_ptr = assembler.LoadObjectField(
elements, FixedTypedArrayBase::kExternalPointerOffset); elements, FixedTypedArrayBase::kExternalPointerOffset,
Node* data_ptr = assembler.IntPtrAdd(base_ptr, external_ptr); MachineType::Pointer());
Node* data_ptr = assembler.IntPtrAdd(
assembler.BitcastTaggedToWord(base_ptr), external_ptr);
static int32_t kInstanceType[] = { static int32_t kInstanceType[] = {
JS_TYPED_ARRAY_KEY_ITERATOR_TYPE, JS_TYPED_ARRAY_KEY_ITERATOR_TYPE,
...@@ -2624,7 +2622,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2624,7 +2622,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
{ {
Node* value_uint8 = assembler.LoadFixedTypedArrayElement( Node* value_uint8 = assembler.LoadFixedTypedArrayElement(
data_ptr, index, UINT8_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS); data_ptr, index, UINT8_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS);
var_value.Bind(assembler.SmiFromWord(value_uint8)); var_value.Bind(assembler.SmiFromWord32(value_uint8));
assembler.Goto(&allocate_entry_if_needed); assembler.Goto(&allocate_entry_if_needed);
} }
...@@ -2632,7 +2630,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2632,7 +2630,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
{ {
Node* value_int8 = assembler.LoadFixedTypedArrayElement( Node* value_int8 = assembler.LoadFixedTypedArrayElement(
data_ptr, index, INT8_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS); data_ptr, index, INT8_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS);
var_value.Bind(assembler.SmiFromWord(value_int8)); var_value.Bind(assembler.SmiFromWord32(value_int8));
assembler.Goto(&allocate_entry_if_needed); assembler.Goto(&allocate_entry_if_needed);
} }
...@@ -2641,7 +2639,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2641,7 +2639,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
Node* value_uint16 = assembler.LoadFixedTypedArrayElement( Node* value_uint16 = assembler.LoadFixedTypedArrayElement(
data_ptr, index, UINT16_ELEMENTS, data_ptr, index, UINT16_ELEMENTS,
CodeStubAssembler::SMI_PARAMETERS); CodeStubAssembler::SMI_PARAMETERS);
var_value.Bind(assembler.SmiFromWord(value_uint16)); var_value.Bind(assembler.SmiFromWord32(value_uint16));
assembler.Goto(&allocate_entry_if_needed); assembler.Goto(&allocate_entry_if_needed);
} }
...@@ -2649,7 +2647,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext( ...@@ -2649,7 +2647,7 @@ void Builtins::Generate_ArrayIteratorPrototypeNext(
{ {
Node* value_int16 = assembler.LoadFixedTypedArrayElement( Node* value_int16 = assembler.LoadFixedTypedArrayElement(
data_ptr, index, INT16_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS); data_ptr, index, INT16_ELEMENTS, CodeStubAssembler::SMI_PARAMETERS);
var_value.Bind(assembler.SmiFromWord(value_int16)); var_value.Bind(assembler.SmiFromWord32(value_int16));
assembler.Goto(&allocate_entry_if_needed); assembler.Goto(&allocate_entry_if_needed);
} }
......
...@@ -953,7 +953,7 @@ void Generate_DatePrototype_GetField(CodeStubAssembler* assembler, ...@@ -953,7 +953,7 @@ void Generate_DatePrototype_GetField(CodeStubAssembler* assembler,
Node* function = assembler->ExternalConstant( Node* function = assembler->ExternalConstant(
ExternalReference::get_date_field_function(assembler->isolate())); ExternalReference::get_date_field_function(assembler->isolate()));
Node* result = assembler->CallCFunction2( Node* result = assembler->CallCFunction2(
MachineType::AnyTagged(), MachineType::Pointer(), MachineType::AnyTagged(), MachineType::AnyTagged(),
MachineType::AnyTagged(), function, receiver, field_index_smi); MachineType::AnyTagged(), function, receiver, field_index_smi);
assembler->Return(result); assembler->Return(result);
} }
......
...@@ -367,10 +367,10 @@ void Builtins::Generate_FastFunctionPrototypeBind( ...@@ -367,10 +367,10 @@ void Builtins::Generate_FastFunctionPrototypeBind(
Label empty_arguments(&assembler); Label empty_arguments(&assembler);
Label arguments_done(&assembler, &argument_array); Label arguments_done(&assembler, &argument_array);
assembler.GotoIf( assembler.GotoIf(
assembler.UintPtrLessThanOrEqual(argc, assembler.IntPtrConstant(1)), assembler.Uint32LessThanOrEqual(argc, assembler.Int32Constant(1)),
&empty_arguments); &empty_arguments);
Node* elements_length = Node* elements_length = assembler.ChangeUint32ToWord(
assembler.IntPtrSub(argc, assembler.IntPtrConstant(1)); assembler.Int32Sub(argc, assembler.Int32Constant(1)));
Node* elements = assembler.AllocateFixedArray( Node* elements = assembler.AllocateFixedArray(
FAST_ELEMENTS, elements_length, CodeStubAssembler::INTPTR_PARAMETERS); FAST_ELEMENTS, elements_length, CodeStubAssembler::INTPTR_PARAMETERS);
Variable index(&assembler, MachineType::PointerRepresentation()); Variable index(&assembler, MachineType::PointerRepresentation());
...@@ -398,7 +398,7 @@ void Builtins::Generate_FastFunctionPrototypeBind( ...@@ -398,7 +398,7 @@ void Builtins::Generate_FastFunctionPrototypeBind(
Variable bound_receiver(&assembler, MachineRepresentation::kTagged); Variable bound_receiver(&assembler, MachineRepresentation::kTagged);
Label has_receiver(&assembler); Label has_receiver(&assembler);
Label receiver_done(&assembler, &bound_receiver); Label receiver_done(&assembler, &bound_receiver);
assembler.GotoIf(assembler.WordNotEqual(argc, assembler.IntPtrConstant(0)), assembler.GotoIf(assembler.Word32NotEqual(argc, assembler.Int32Constant(0)),
&has_receiver); &has_receiver);
bound_receiver.Bind(assembler.UndefinedConstant()); bound_receiver.Bind(assembler.UndefinedConstant());
assembler.Goto(&receiver_done); assembler.Goto(&receiver_done);
......
...@@ -67,7 +67,7 @@ void Builtins::Generate_CopyFastSmiOrObjectElements( ...@@ -67,7 +67,7 @@ void Builtins::Generate_CopyFastSmiOrObjectElements(
Node* source = assembler.LoadObjectField(object, JSObject::kElementsOffset); Node* source = assembler.LoadObjectField(object, JSObject::kElementsOffset);
CodeStubAssembler::ParameterMode mode = assembler.OptimalParameterMode(); CodeStubAssembler::ParameterMode mode = assembler.OptimalParameterMode();
Node* length = assembler.UntagParameter( Node* length = assembler.TaggedToParameter(
assembler.LoadFixedArrayBaseLength(source), mode); assembler.LoadFixedArrayBaseLength(source), mode);
// Check if we can allocate in new space. // Check if we can allocate in new space.
......
...@@ -272,7 +272,8 @@ compiler::Node* PromiseHasHandler(CodeStubAssembler* a, ...@@ -272,7 +272,8 @@ compiler::Node* PromiseHasHandler(CodeStubAssembler* a,
void PromiseSetHasHandler(CodeStubAssembler* a, compiler::Node* promise) { void PromiseSetHasHandler(CodeStubAssembler* a, compiler::Node* promise) {
typedef compiler::Node Node; typedef compiler::Node Node;
Node* const flags = a->LoadObjectField(promise, JSPromise::kFlagsOffset); Node* const flags =
a->SmiUntag(a->LoadObjectField(promise, JSPromise::kFlagsOffset));
Node* const new_flags = Node* const new_flags =
a->WordOr(flags, a->IntPtrConstant(1 << JSPromise::kHasHandlerBit)); a->WordOr(flags, a->IntPtrConstant(1 << JSPromise::kHasHandlerBit));
a->StoreObjectField(promise, JSPromise::kFlagsOffset, a->SmiTag(new_flags)); a->StoreObjectField(promise, JSPromise::kFlagsOffset, a->SmiTag(new_flags));
...@@ -345,10 +346,10 @@ void AppendPromiseCallback(CodeStubAssembler* a, int offset, ...@@ -345,10 +346,10 @@ void AppendPromiseCallback(CodeStubAssembler* a, int offset,
Node* elements = a->LoadObjectField(promise, offset); Node* elements = a->LoadObjectField(promise, offset);
Node* length = a->LoadFixedArrayBaseLength(elements); Node* length = a->LoadFixedArrayBaseLength(elements);
CodeStubAssembler::ParameterMode mode = a->OptimalParameterMode(); CodeStubAssembler::ParameterMode mode = a->OptimalParameterMode();
length = a->UntagParameter(length, mode); length = a->TaggedToParameter(length, mode);
Node* delta = a->IntPtrOrSmiConstant(1, mode); Node* delta = a->IntPtrOrSmiConstant(1, mode);
Node* new_capacity = a->IntPtrAdd(length, delta); Node* new_capacity = a->IntPtrOrSmiAdd(length, delta, mode);
const ElementsKind kind = FAST_ELEMENTS; const ElementsKind kind = FAST_ELEMENTS;
const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER; const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER;
......
...@@ -183,16 +183,19 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(Node* context, ...@@ -183,16 +183,19 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(Node* context,
{ {
Node* const from_cursor = var_from_cursor.value(); Node* const from_cursor = var_from_cursor.value();
Node* const to_cursor = var_to_cursor.value(); Node* const to_cursor = var_to_cursor.value();
Node* const start = LoadFixedArrayElement(match_info, from_cursor); Node* const start =
LoadFixedArrayElement(match_info, from_cursor, 0, INTPTR_PARAMETERS);
Label next_iter(this); Label next_iter(this);
GotoIf(SmiEqual(start, SmiConstant(Smi::FromInt(-1))), &next_iter); GotoIf(SmiEqual(start, SmiConstant(Smi::FromInt(-1))), &next_iter);
Node* const from_cursor_plus1 = IntPtrAdd(from_cursor, IntPtrConstant(1)); Node* const from_cursor_plus1 = IntPtrAdd(from_cursor, IntPtrConstant(1));
Node* const end = LoadFixedArrayElement(match_info, from_cursor_plus1); Node* const end = LoadFixedArrayElement(match_info, from_cursor_plus1, 0,
INTPTR_PARAMETERS);
Node* const capture = SubString(context, string, start, end); Node* const capture = SubString(context, string, start, end);
StoreFixedArrayElement(result_elements, to_cursor, capture); StoreFixedArrayElement(result_elements, to_cursor, capture,
UPDATE_WRITE_BARRIER, 0, INTPTR_PARAMETERS);
Goto(&next_iter); Goto(&next_iter);
Bind(&next_iter); Bind(&next_iter);
...@@ -566,7 +569,7 @@ Node* RegExpBuiltinsAssembler::FlagsGetter(Node* const context, ...@@ -566,7 +569,7 @@ Node* RegExpBuiltinsAssembler::FlagsGetter(Node* const context,
do { \ do { \
Label next(this); \ Label next(this); \
GotoUnless(IsSetWord(flags_intptr, FLAG), &next); \ GotoUnless(IsSetWord(flags_intptr, FLAG), &next); \
Node* const value = IntPtrConstant(CHAR); \ Node* const value = Int32Constant(CHAR); \
StoreNoWriteBarrier(MachineRepresentation::kWord8, result, \ StoreNoWriteBarrier(MachineRepresentation::kWord8, result, \
var_offset.value(), value); \ var_offset.value(), value); \
var_offset.Bind(IntPtrAdd(var_offset.value(), int_one)); \ var_offset.Bind(IntPtrAdd(var_offset.value(), int_one)); \
...@@ -590,8 +593,8 @@ Node* RegExpBuiltinsAssembler::IsRegExp(Node* const context, ...@@ -590,8 +593,8 @@ Node* RegExpBuiltinsAssembler::IsRegExp(Node* const context,
Node* const maybe_receiver) { Node* const maybe_receiver) {
Label out(this), if_isregexp(this); Label out(this), if_isregexp(this);
Variable var_result(this, MachineType::PointerRepresentation()); Variable var_result(this, MachineRepresentation::kWord32);
var_result.Bind(IntPtrConstant(0)); var_result.Bind(Int32Constant(0));
GotoIf(TaggedIsSmi(maybe_receiver), &out); GotoIf(TaggedIsSmi(maybe_receiver), &out);
GotoUnless(IsJSReceiver(maybe_receiver), &out); GotoUnless(IsJSReceiver(maybe_receiver), &out);
...@@ -615,7 +618,7 @@ Node* RegExpBuiltinsAssembler::IsRegExp(Node* const context, ...@@ -615,7 +618,7 @@ Node* RegExpBuiltinsAssembler::IsRegExp(Node* const context,
} }
Bind(&if_isregexp); Bind(&if_isregexp);
var_result.Bind(IntPtrConstant(1)); var_result.Bind(Int32Constant(1));
Goto(&out); Goto(&out);
Bind(&out); Bind(&out);
...@@ -962,7 +965,7 @@ Node* RegExpBuiltinsAssembler::FastFlagGetter(Node* const regexp, ...@@ -962,7 +965,7 @@ Node* RegExpBuiltinsAssembler::FastFlagGetter(Node* const regexp,
Node* const smi_zero = SmiConstant(Smi::kZero); Node* const smi_zero = SmiConstant(Smi::kZero);
Node* const flags = LoadObjectField(regexp, JSRegExp::kFlagsOffset); Node* const flags = LoadObjectField(regexp, JSRegExp::kFlagsOffset);
Node* const mask = SmiConstant(Smi::FromInt(flag)); Node* const mask = SmiConstant(Smi::FromInt(flag));
Node* const is_flag_set = WordNotEqual(WordAnd(flags, mask), smi_zero); Node* const is_flag_set = WordNotEqual(SmiAnd(flags, mask), smi_zero);
return is_flag_set; return is_flag_set;
} }
...@@ -974,7 +977,7 @@ Node* RegExpBuiltinsAssembler::SlowFlagGetter(Node* const context, ...@@ -974,7 +977,7 @@ Node* RegExpBuiltinsAssembler::SlowFlagGetter(Node* const context,
Factory* factory = isolate()->factory(); Factory* factory = isolate()->factory();
Label out(this); Label out(this);
Variable var_result(this, MachineType::PointerRepresentation()); Variable var_result(this, MachineRepresentation::kWord32);
Node* name; Node* name;
...@@ -1006,13 +1009,13 @@ Node* RegExpBuiltinsAssembler::SlowFlagGetter(Node* const context, ...@@ -1006,13 +1009,13 @@ Node* RegExpBuiltinsAssembler::SlowFlagGetter(Node* const context,
Bind(&if_true); Bind(&if_true);
{ {
var_result.Bind(IntPtrConstant(1)); var_result.Bind(Int32Constant(1));
Goto(&out); Goto(&out);
} }
Bind(&if_false); Bind(&if_false);
{ {
var_result.Bind(IntPtrConstant(0)); var_result.Bind(Int32Constant(0));
Goto(&out); Goto(&out);
} }
...@@ -2249,7 +2252,8 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath( ...@@ -2249,7 +2252,8 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
var_match_start.value(), string); var_match_start.value(), string);
Node* const replacement_str = ToString(context, replacement_obj); Node* const replacement_str = ToString(context, replacement_obj);
StoreFixedArrayElement(res_elems, i, replacement_str); StoreFixedArrayElement(res_elems, i, replacement_str,
UPDATE_WRITE_BARRIER, 0, mode);
Node* const elem_length = LoadStringLength(elem); Node* const elem_length = LoadStringLength(elem);
Node* const new_match_start = Node* const new_match_start =
...@@ -2439,8 +2443,6 @@ TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) { ...@@ -2439,8 +2443,6 @@ TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) {
Node* const replace_value = Parameter(2); Node* const replace_value = Parameter(2);
Node* const context = Parameter(5); Node* const context = Parameter(5);
Node* const int_zero = IntPtrConstant(0);
// Ensure {maybe_receiver} is a JSReceiver. // Ensure {maybe_receiver} is a JSReceiver.
Node* const map = ThrowIfNotJSReceiver( Node* const map = ThrowIfNotJSReceiver(
context, maybe_receiver, MessageTemplate::kIncompatibleMethodReceiver, context, maybe_receiver, MessageTemplate::kIncompatibleMethodReceiver,
...@@ -2472,10 +2474,10 @@ TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) { ...@@ -2472,10 +2474,10 @@ TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) {
Node* const replace_string = Node* const replace_string =
CallStub(tostring_callable, context, replace_value); CallStub(tostring_callable, context, replace_value);
Node* const dollar_char = IntPtrConstant('$'); Node* const dollar_char = Int32Constant('$');
Node* const smi_minusone = SmiConstant(Smi::FromInt(-1)); Node* const smi_minusone = SmiConstant(Smi::FromInt(-1));
GotoUnless(SmiEqual(StringIndexOfChar(context, replace_string, dollar_char, GotoUnless(SmiEqual(StringIndexOfChar(context, replace_string, dollar_char,
int_zero), SmiConstant(0)),
smi_minusone), smi_minusone),
&runtime); &runtime);
......
...@@ -43,7 +43,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged, ...@@ -43,7 +43,7 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged,
// Fail if the array's instance type is not JSTypedArray. // Fail if the array's instance type is not JSTypedArray.
a->Bind(&not_smi); a->Bind(&not_smi);
a->Branch(a->WordEqual(a->LoadInstanceType(tagged), a->Branch(a->Word32Equal(a->LoadInstanceType(tagged),
a->Int32Constant(JS_TYPED_ARRAY_TYPE)), a->Int32Constant(JS_TYPED_ARRAY_TYPE)),
&is_typed_array, &not_typed_array); &is_typed_array, &not_typed_array);
a->Bind(&not_typed_array); a->Bind(&not_typed_array);
...@@ -88,7 +88,8 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged, ...@@ -88,7 +88,8 @@ void ValidateSharedTypedArray(CodeStubAssembler* a, compiler::Node* tagged,
Node* byte_offset = a->ChangeUint32ToWord(a->TruncateTaggedToWord32( Node* byte_offset = a->ChangeUint32ToWord(a->TruncateTaggedToWord32(
context, context,
a->LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset))); a->LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset)));
*out_backing_store = a->IntPtrAdd(backing_store, byte_offset); *out_backing_store =
a->IntPtrAdd(a->BitcastTaggedToWord(backing_store), byte_offset);
} }
// https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess
...@@ -144,7 +145,7 @@ void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word, ...@@ -144,7 +145,7 @@ void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word,
CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a); CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a);
// TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length". // TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length".
a->Branch( a->Branch(
a->WordOr(a->Int32LessThan(index_word, a->Int32Constant(0)), a->Word32Or(a->Int32LessThan(index_word, a->Int32Constant(0)),
a->Int32GreaterThanOrEqual(index_word, array_length_word)), a->Int32GreaterThanOrEqual(index_word, array_length_word)),
&if_notinbounds, &if_inbounds); &if_notinbounds, &if_inbounds);
a->Bind(&if_notinbounds); a->Bind(&if_notinbounds);
...@@ -185,19 +186,19 @@ void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) { ...@@ -185,19 +186,19 @@ void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) {
arraysize(case_labels)); arraysize(case_labels));
a.Bind(&i8); a.Bind(&i8);
a.Return( a.Return(a.SmiFromWord32(
a.SmiTag(a.AtomicLoad(MachineType::Int8(), backing_store, index_word))); a.AtomicLoad(MachineType::Int8(), backing_store, index_word)));
a.Bind(&u8); a.Bind(&u8);
a.Return( a.Return(a.SmiFromWord32(
a.SmiTag(a.AtomicLoad(MachineType::Uint8(), backing_store, index_word))); a.AtomicLoad(MachineType::Uint8(), backing_store, index_word)));
a.Bind(&i16); a.Bind(&i16);
a.Return(a.SmiTag(a.AtomicLoad(MachineType::Int16(), backing_store, a.Return(a.SmiFromWord32(a.AtomicLoad(MachineType::Int16(), backing_store,
a.WordShl(index_word, 1)))); a.WordShl(index_word, 1))));
a.Bind(&u16); a.Bind(&u16);
a.Return(a.SmiTag(a.AtomicLoad(MachineType::Uint16(), backing_store, a.Return(a.SmiFromWord32(a.AtomicLoad(MachineType::Uint16(), backing_store,
a.WordShl(index_word, 1)))); a.WordShl(index_word, 1))));
a.Bind(&i32); a.Bind(&i32);
...@@ -210,7 +211,7 @@ void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) { ...@@ -210,7 +211,7 @@ void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) {
// This shouldn't happen, we've already validated the type. // This shouldn't happen, we've already validated the type.
a.Bind(&other); a.Bind(&other);
a.Return(a.Int32Constant(0)); a.Return(a.SmiConstant(0));
} }
void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) { void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) {
...@@ -262,7 +263,7 @@ void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) { ...@@ -262,7 +263,7 @@ void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) {
// This shouldn't happen, we've already validated the type. // This shouldn't happen, we've already validated the type.
a.Bind(&other); a.Bind(&other);
a.Return(a.Int32Constant(0)); a.Return(a.SmiConstant(0));
} }
} // namespace internal } // namespace internal
......
...@@ -434,11 +434,12 @@ void Builtins::Generate_StringFromCharCode( ...@@ -434,11 +434,12 @@ void Builtins::Generate_StringFromCharCode(
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state); CodeStubAssembler assembler(state);
Node* argc = assembler.ChangeInt32ToIntPtr( Node* argc = assembler.Parameter(BuiltinDescriptor::kArgumentsCount);
assembler.Parameter(BuiltinDescriptor::kArgumentsCount));
Node* context = assembler.Parameter(BuiltinDescriptor::kContext); Node* context = assembler.Parameter(BuiltinDescriptor::kContext);
CodeStubArguments arguments(&assembler, argc); CodeStubArguments arguments(&assembler, argc);
// From now on use word-size argc value.
argc = arguments.GetLength();
// Check if we have exactly one argument (plus the implicit receiver), i.e. // Check if we have exactly one argument (plus the implicit receiver), i.e.
// if the parent frame is not an arguments adaptor frame. // if the parent frame is not an arguments adaptor frame.
...@@ -1312,7 +1313,7 @@ compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler, ...@@ -1312,7 +1313,7 @@ compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler,
typedef CodeStubAssembler::Variable Variable; typedef CodeStubAssembler::Variable Variable;
Label handle_surrogate_pair(assembler), return_result(assembler); Label handle_surrogate_pair(assembler), return_result(assembler);
Variable var_result(assembler, MachineRepresentation::kWord32); Variable var_result(assembler, MachineRepresentation::kWord32);
Variable var_trail(assembler, MachineRepresentation::kWord16); Variable var_trail(assembler, MachineRepresentation::kWord32);
var_result.Bind(assembler->StringCharCodeAt(string, index)); var_result.Bind(assembler->StringCharCodeAt(string, index));
var_trail.Bind(assembler->Int32Constant(0)); var_trail.Bind(assembler->Int32Constant(0));
...@@ -1350,12 +1351,12 @@ compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler, ...@@ -1350,12 +1351,12 @@ compiler::Node* LoadSurrogatePairInternal(CodeStubAssembler* assembler,
switch (encoding) { switch (encoding) {
case UnicodeEncoding::UTF16: case UnicodeEncoding::UTF16:
var_result.Bind(assembler->WordOr( var_result.Bind(assembler->Word32Or(
// Need to swap the order for big-endian platforms // Need to swap the order for big-endian platforms
#if V8_TARGET_BIG_ENDIAN #if V8_TARGET_BIG_ENDIAN
assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); assembler->Word32Shl(lead, assembler->Int32Constant(16)), trail));
#else #else
assembler->WordShl(trail, assembler->Int32Constant(16)), lead)); assembler->Word32Shl(trail, assembler->Int32Constant(16)), lead));
#endif #endif
break; break;
...@@ -1410,7 +1411,7 @@ void Builtins::Generate_StringIteratorPrototypeNext( ...@@ -1410,7 +1411,7 @@ void Builtins::Generate_StringIteratorPrototypeNext(
assembler.GotoIf(assembler.TaggedIsSmi(iterator), &throw_bad_receiver); assembler.GotoIf(assembler.TaggedIsSmi(iterator), &throw_bad_receiver);
assembler.GotoUnless( assembler.GotoUnless(
assembler.WordEqual(assembler.LoadInstanceType(iterator), assembler.Word32Equal(assembler.LoadInstanceType(iterator),
assembler.Int32Constant(JS_STRING_ITERATOR_TYPE)), assembler.Int32Constant(JS_STRING_ITERATOR_TYPE)),
&throw_bad_receiver); &throw_bad_receiver);
......
...@@ -89,7 +89,8 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, ...@@ -89,7 +89,8 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate,
compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags, compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv, flags,
name); name);
generator(&state); generator(&state);
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state); Handle<Code> code =
compiler::CodeAssembler::GenerateCode(&state, FLAG_csa_verify);
PostBuildProfileAndTracing(isolate, *code, name); PostBuildProfileAndTracing(isolate, *code, name);
return *code; return *code;
} }
......
...@@ -126,9 +126,11 @@ Node* CodeStubAssembler::StaleRegisterConstant() { ...@@ -126,9 +126,11 @@ Node* CodeStubAssembler::StaleRegisterConstant() {
Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) { Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) {
if (mode == SMI_PARAMETERS) { if (mode == SMI_PARAMETERS) {
return SmiConstant(Smi::FromInt(value)); return SmiConstant(Smi::FromInt(value));
} else { } else if (mode == INTPTR_PARAMETERS) {
DCHECK(mode == INTEGER_PARAMETERS || mode == INTPTR_PARAMETERS);
return IntPtrConstant(value); return IntPtrConstant(value);
} else {
DCHECK_EQ(INTEGER_PARAMETERS, mode);
return Int32Constant(value);
} }
} }
...@@ -726,7 +728,7 @@ void CodeStubAssembler::BranchIfFastJSArray( ...@@ -726,7 +728,7 @@ void CodeStubAssembler::BranchIfFastJSArray(
Node* map = LoadMap(object); Node* map = LoadMap(object);
// Bailout if instance type is not JS_ARRAY_TYPE. // Bailout if instance type is not JS_ARRAY_TYPE.
GotoIf(WordNotEqual(LoadMapInstanceType(map), Int32Constant(JS_ARRAY_TYPE)), GotoIf(Word32NotEqual(LoadMapInstanceType(map), Int32Constant(JS_ARRAY_TYPE)),
if_false); if_false);
Node* elements_kind = LoadMapElementsKind(map); Node* elements_kind = LoadMapElementsKind(map);
...@@ -1461,35 +1463,37 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context, ...@@ -1461,35 +1463,37 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context,
Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); Comment("BuildAppendJSArray: %s", ElementsKindToString(kind));
Label pre_bailout(this); Label pre_bailout(this);
Label success(this); Label success(this);
Variable elements(this, MachineRepresentation::kTagged); Variable var_elements(this, MachineRepresentation::kTagged);
Variable var_tagged_length(this, MachineRepresentation::kTagged);
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
Variable length(this, OptimalParameterRepresentation()); Variable var_length(this, OptimalParameterRepresentation());
length.Bind(UntagParameter(LoadJSArrayLength(array), mode)); var_length.Bind(TaggedToParameter(LoadJSArrayLength(array), mode));
elements.Bind(LoadElements(array)); var_elements.Bind(LoadElements(array));
Node* capacity = Node* capacity =
UntagParameter(LoadFixedArrayBaseLength(elements.value()), mode); TaggedToParameter(LoadFixedArrayBaseLength(var_elements.value()), mode);
// Resize the capacity of the fixed array if it doesn't fit. // Resize the capacity of the fixed array if it doesn't fit.
Label fits(this, &elements); Label fits(this, &var_elements);
Node* first = arg_index.value(); Node* first = arg_index.value();
Node* growth = IntPtrSubFoldConstants(args.GetLength(), first); Node* growth = IntPtrSubFoldConstants(args.GetLength(), first);
Node* new_length = IntPtrAdd( Node* new_length =
mode == INTPTR_PARAMETERS ? growth : SmiTag(growth), length.value()); IntPtrOrSmiAdd(WordToParameter(growth, mode), var_length.value(), mode);
GotoUnless(IntPtrGreaterThanOrEqual(new_length, capacity), &fits); GotoUnless(IntPtrOrSmiGreaterThanOrEqual(new_length, capacity, mode), &fits);
Node* new_capacity = CalculateNewElementsCapacity( Node* new_capacity = CalculateNewElementsCapacity(
IntPtrAdd(new_length, IntPtrOrSmiConstant(1, mode)), mode); IntPtrOrSmiAdd(new_length, IntPtrOrSmiConstant(1, mode), mode), mode);
elements.Bind(GrowElementsCapacity(array, elements.value(), kind, kind, var_elements.Bind(GrowElementsCapacity(array, var_elements.value(), kind,
capacity, new_capacity, mode, kind, capacity, new_capacity, mode,
&pre_bailout)); &pre_bailout));
Goto(&fits); Goto(&fits);
Bind(&fits); Bind(&fits);
Node* elements = var_elements.value();
// Push each argument onto the end of the array now that there is enough // Push each argument onto the end of the array now that there is enough
// capacity. // capacity.
CodeStubAssembler::VariableList push_vars({&length, &elements}, zone()); CodeStubAssembler::VariableList push_vars({&var_length}, zone());
args.ForEach( args.ForEach(
push_vars, push_vars,
[this, kind, mode, &length, &elements, &pre_bailout](Node* arg) { [this, kind, mode, elements, &var_length, &pre_bailout](Node* arg) {
if (IsFastSmiElementsKind(kind)) { if (IsFastSmiElementsKind(kind)) {
GotoIf(TaggedIsNotSmi(arg), &pre_bailout); GotoIf(TaggedIsNotSmi(arg), &pre_bailout);
} else if (IsFastDoubleElementsKind(kind)) { } else if (IsFastDoubleElementsKind(kind)) {
...@@ -1497,31 +1501,37 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context, ...@@ -1497,31 +1501,37 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context,
} }
if (IsFastDoubleElementsKind(kind)) { if (IsFastDoubleElementsKind(kind)) {
Node* double_value = ChangeNumberToFloat64(arg); Node* double_value = ChangeNumberToFloat64(arg);
StoreFixedDoubleArrayElement(elements.value(), length.value(), StoreFixedDoubleArrayElement(elements, var_length.value(),
Float64SilenceNaN(double_value), mode); Float64SilenceNaN(double_value), mode);
} else { } else {
WriteBarrierMode barrier_mode = IsFastSmiElementsKind(kind) WriteBarrierMode barrier_mode = IsFastSmiElementsKind(kind)
? SKIP_WRITE_BARRIER ? SKIP_WRITE_BARRIER
: UPDATE_WRITE_BARRIER; : UPDATE_WRITE_BARRIER;
StoreFixedArrayElement(elements.value(), length.value(), arg, StoreFixedArrayElement(elements, var_length.value(), arg,
barrier_mode, 0, mode); barrier_mode, 0, mode);
} }
Increment(length, 1, mode); Increment(var_length, 1, mode);
}, },
first, nullptr); first, nullptr);
length.Bind(TagParameter(length.value(), mode)); {
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length.value()); Node* length = ParameterToTagged(var_length.value(), mode);
var_tagged_length.Bind(length);
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
Goto(&success); Goto(&success);
}
Bind(&pre_bailout); Bind(&pre_bailout);
length.Bind(TagParameter(length.value(), mode)); {
Node* diff = SmiSub(length.value(), LoadJSArrayLength(array)); Node* length = ParameterToTagged(var_length.value(), mode);
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length.value()); var_tagged_length.Bind(length);
Node* diff = SmiSub(length, LoadJSArrayLength(array));
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
arg_index.Bind(IntPtrAdd(arg_index.value(), SmiUntag(diff))); arg_index.Bind(IntPtrAdd(arg_index.value(), SmiUntag(diff)));
Goto(bailout); Goto(bailout);
}
Bind(&success); Bind(&success);
return length.value(); return var_tagged_length.value();
} }
Node* CodeStubAssembler::AllocateHeapNumber(MutableMode mode) { Node* CodeStubAssembler::AllocateHeapNumber(MutableMode mode) {
...@@ -1578,7 +1588,7 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, ...@@ -1578,7 +1588,7 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length,
DCHECK(Heap::RootIsImmortalImmovable(Heap::kOneByteStringMapRootIndex)); DCHECK(Heap::RootIsImmortalImmovable(Heap::kOneByteStringMapRootIndex));
StoreMapNoWriteBarrier(result, Heap::kOneByteStringMapRootIndex); StoreMapNoWriteBarrier(result, Heap::kOneByteStringMapRootIndex);
StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset,
TagParameter(length, mode)); ParameterToTagged(length, mode));
// Initialize both used and unused parts of hash field slot at once. // Initialize both used and unused parts of hash field slot at once.
StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot,
IntPtrConstant(String::kEmptyHashField), IntPtrConstant(String::kEmptyHashField),
...@@ -1591,7 +1601,7 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, ...@@ -1591,7 +1601,7 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length,
{ {
// We might need to allocate in large object space, go to the runtime. // We might need to allocate in large object space, go to the runtime.
Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context, Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context,
TagParameter(length, mode)); ParameterToTagged(length, mode));
var_result.Bind(result); var_result.Bind(result);
Goto(&if_join); Goto(&if_join);
} }
...@@ -1876,13 +1886,13 @@ Node* CodeStubAssembler::AllocateNameDictionary(Node* at_least_space_for) { ...@@ -1876,13 +1886,13 @@ Node* CodeStubAssembler::AllocateNameDictionary(Node* at_least_space_for) {
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
// Initialize NameDictionary elements. // Initialize NameDictionary elements.
result = BitcastTaggedToWord(result); Node* result_word = BitcastTaggedToWord(result);
Node* start_address = IntPtrAdd( Node* start_address = IntPtrAdd(
result, IntPtrConstant(NameDictionary::OffsetOfElementAt( result_word, IntPtrConstant(NameDictionary::OffsetOfElementAt(
NameDictionary::kElementsStartIndex) - NameDictionary::kElementsStartIndex) -
kHeapObjectTag)); kHeapObjectTag));
Node* end_address = IntPtrAdd( Node* end_address = IntPtrAdd(
result, result_word,
IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag))); IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag)));
StoreFieldsNoWriteBarrier(start_address, end_address, filler); StoreFieldsNoWriteBarrier(start_address, end_address, filler);
return result; return result;
...@@ -1928,6 +1938,7 @@ void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map, ...@@ -1928,6 +1938,7 @@ void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map,
Comment("InitializeJSObjectBody"); Comment("InitializeJSObjectBody");
Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex);
// Calculate the untagged field addresses. // Calculate the untagged field addresses.
object = BitcastTaggedToWord(object);
Node* start_address = Node* start_address =
IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag)); IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag));
Node* end_address = Node* end_address =
...@@ -2026,7 +2037,7 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, ...@@ -2026,7 +2037,7 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
DCHECK(Heap::RootIsImmortalImmovable(elements_map_index)); DCHECK(Heap::RootIsImmortalImmovable(elements_map_index));
StoreMapNoWriteBarrier(elements, elements_map_index); StoreMapNoWriteBarrier(elements, elements_map_index);
StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset,
TagParameter(capacity, capacity_mode)); ParameterToTagged(capacity, capacity_mode));
// Fill in the elements with holes. // Fill in the elements with holes.
FillFixedArrayWithValue(kind, elements, IntPtrOrSmiConstant(0, capacity_mode), FillFixedArrayWithValue(kind, elements, IntPtrOrSmiConstant(0, capacity_mode),
...@@ -2052,7 +2063,7 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, ...@@ -2052,7 +2063,7 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
DCHECK(Heap::RootIsImmortalImmovable(map_index)); DCHECK(Heap::RootIsImmortalImmovable(map_index));
StoreMapNoWriteBarrier(array, map_index); StoreMapNoWriteBarrier(array, map_index);
StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset,
TagParameter(capacity_node, mode)); ParameterToTagged(capacity_node, mode));
return array; return array;
} }
...@@ -2344,8 +2355,8 @@ Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, ...@@ -2344,8 +2355,8 @@ Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
Node* capacity = LoadFixedArrayBaseLength(elements); Node* capacity = LoadFixedArrayBaseLength(elements);
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
capacity = UntagParameter(capacity, mode); capacity = TaggedToParameter(capacity, mode);
key = UntagParameter(key, mode); key = TaggedToParameter(key, mode);
return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode, return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode,
bailout); bailout);
...@@ -2721,7 +2732,7 @@ Node* CodeStubAssembler::ChangeNumberToFloat64(compiler::Node* value) { ...@@ -2721,7 +2732,7 @@ Node* CodeStubAssembler::ChangeNumberToFloat64(compiler::Node* value) {
Bind(&smi); Bind(&smi);
{ {
result.Bind(ChangeInt32ToFloat64(SmiUntag(value))); result.Bind(SmiToFloat64(value));
Goto(&done); Goto(&done);
} }
...@@ -3577,8 +3588,9 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, ...@@ -3577,8 +3588,9 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
// Let runtime handle non-one-byte {needle_char}. // Let runtime handle non-one-byte {needle_char}.
Node* const one_byte_char_mask = IntPtrConstant(0xFF); Node* const one_byte_char_mask = Int32Constant(0xFF);
GotoUnless(WordEqual(WordAnd(needle_char, one_byte_char_mask), needle_char), GotoUnless(
Word32Equal(Word32And(needle_char, one_byte_char_mask), needle_char),
&runtime); &runtime);
// TODO(jgruber): Handle external and two-byte strings. // TODO(jgruber): Handle external and two-byte strings.
...@@ -3609,7 +3621,7 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, ...@@ -3609,7 +3621,7 @@ Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
[this, string, needle_char, begin, &var_result, &out](Node* cursor) { [this, string, needle_char, begin, &var_result, &out](Node* cursor) {
Label next(this); Label next(this);
Node* value = Load(MachineType::Uint8(), string, cursor); Node* value = Load(MachineType::Uint8(), string, cursor);
GotoUnless(WordEqual(value, needle_char), &next); GotoUnless(Word32Equal(value, needle_char), &next);
// Found a match. // Found a match.
Node* index = SmiTag(IntPtrSub(cursor, begin)); Node* index = SmiTag(IntPtrSub(cursor, begin));
...@@ -4268,7 +4280,8 @@ void CodeStubAssembler::Increment(Variable& variable, int value, ...@@ -4268,7 +4280,8 @@ void CodeStubAssembler::Increment(Variable& variable, int value,
DCHECK_IMPLIES(mode == SMI_PARAMETERS, DCHECK_IMPLIES(mode == SMI_PARAMETERS,
variable.rep() == MachineRepresentation::kTagged || variable.rep() == MachineRepresentation::kTagged ||
variable.rep() == MachineRepresentation::kTaggedSigned); variable.rep() == MachineRepresentation::kTaggedSigned);
variable.Bind(IntPtrAdd(variable.value(), IntPtrOrSmiConstant(value, mode))); variable.Bind(
IntPtrOrSmiAdd(variable.value(), IntPtrOrSmiConstant(value, mode), mode));
} }
void CodeStubAssembler::Use(Label* label) { void CodeStubAssembler::Use(Label* label) {
...@@ -5496,7 +5509,7 @@ void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) { ...@@ -5496,7 +5509,7 @@ void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) {
Node* length = LoadFixedArrayBaseLength(properties); Node* length = LoadFixedArrayBaseLength(properties);
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
length = UntagParameter(length, mode); length = TaggedToParameter(length, mode);
Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode); Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode);
Node* new_capacity = IntPtrOrSmiAdd(length, delta, mode); Node* new_capacity = IntPtrOrSmiAdd(length, delta, mode);
...@@ -5883,14 +5896,10 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value, ...@@ -5883,14 +5896,10 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value,
// Check if buffer has been neutered. // Check if buffer has been neutered.
Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset); Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset);
Node* bitfield = LoadObjectField(buffer, JSArrayBuffer::kBitFieldOffset, GotoIf(IsDetachedBuffer(buffer), bailout);
MachineType::Uint32());
Node* neutered_bit =
Word32And(bitfield, Int32Constant(JSArrayBuffer::WasNeutered::kMask));
GotoUnless(Word32Equal(neutered_bit, Int32Constant(0)), bailout);
// Bounds check. // Bounds check.
Node* length = UntagParameter( Node* length = TaggedToParameter(
LoadObjectField(object, JSTypedArray::kLengthOffset), parameter_mode); LoadObjectField(object, JSTypedArray::kLengthOffset), parameter_mode);
if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
...@@ -5908,7 +5917,8 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value, ...@@ -5908,7 +5917,8 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value,
MachineType::Pointer()); MachineType::Pointer());
Node* base_pointer = Node* base_pointer =
LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset); LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset);
Node* backing_store = IntPtrAdd(external_pointer, base_pointer); Node* backing_store =
IntPtrAdd(external_pointer, BitcastTaggedToWord(base_pointer));
StoreElement(backing_store, elements_kind, key, value, parameter_mode); StoreElement(backing_store, elements_kind, key, value, parameter_mode);
Goto(&done); Goto(&done);
...@@ -5920,7 +5930,7 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value, ...@@ -5920,7 +5930,7 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value,
Node* length = is_jsarray ? LoadObjectField(object, JSArray::kLengthOffset) Node* length = is_jsarray ? LoadObjectField(object, JSArray::kLengthOffset)
: LoadFixedArrayBaseLength(elements); : LoadFixedArrayBaseLength(elements);
length = UntagParameter(length, parameter_mode); length = TaggedToParameter(length, parameter_mode);
// In case value is stored into a fast smi array, assure that the value is // In case value is stored into a fast smi array, assure that the value is
// a smi before manipulating the backing store. Otherwise the backing store // a smi before manipulating the backing store. Otherwise the backing store
...@@ -5965,7 +5975,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements, ...@@ -5965,7 +5975,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements,
Bind(&grow_case); Bind(&grow_case);
{ {
Node* current_capacity = Node* current_capacity =
UntagParameter(LoadFixedArrayBaseLength(elements), mode); TaggedToParameter(LoadFixedArrayBaseLength(elements), mode);
checked_elements.Bind(elements); checked_elements.Bind(elements);
...@@ -5983,7 +5993,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements, ...@@ -5983,7 +5993,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(Node* object, Node* elements,
if (is_js_array) { if (is_js_array) {
Node* new_length = IntPtrAdd(key, IntPtrOrSmiConstant(1, mode)); Node* new_length = IntPtrAdd(key, IntPtrOrSmiConstant(1, mode));
StoreObjectFieldNoWriteBarrier(object, JSArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(object, JSArray::kLengthOffset,
TagParameter(new_length, mode)); ParameterToTagged(new_length, mode));
} }
Goto(&done); Goto(&done);
} }
...@@ -6011,7 +6021,8 @@ Node* CodeStubAssembler::CopyElementsOnWrite(Node* object, Node* elements, ...@@ -6011,7 +6021,8 @@ Node* CodeStubAssembler::CopyElementsOnWrite(Node* object, Node* elements,
WordEqual(LoadMap(elements), LoadRoot(Heap::kFixedCOWArrayMapRootIndex)), WordEqual(LoadMap(elements), LoadRoot(Heap::kFixedCOWArrayMapRootIndex)),
&done); &done);
{ {
Node* capacity = UntagParameter(LoadFixedArrayBaseLength(elements), mode); Node* capacity =
TaggedToParameter(LoadFixedArrayBaseLength(elements), mode);
Node* new_elements = GrowElementsCapacity(object, elements, kind, kind, Node* new_elements = GrowElementsCapacity(object, elements, kind, kind,
length, capacity, mode, bailout); length, capacity, mode, bailout);
...@@ -7567,11 +7578,11 @@ Node* CodeStubAssembler::StrictEqual(ResultMode mode, Node* lhs, Node* rhs, ...@@ -7567,11 +7578,11 @@ Node* CodeStubAssembler::StrictEqual(ResultMode mode, Node* lhs, Node* rhs,
// This algorithm differs from the Strict Equality Comparison Algorithm in its // This algorithm differs from the Strict Equality Comparison Algorithm in its
// treatment of signed zeroes and NaNs. // treatment of signed zeroes and NaNs.
Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) { Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) {
Variable var_result(this, MachineType::PointerRepresentation()); Variable var_result(this, MachineRepresentation::kWord32);
Label strict_equal(this), out(this); Label strict_equal(this), out(this);
Node* const int_false = IntPtrConstant(0); Node* const int_false = Int32Constant(0);
Node* const int_true = IntPtrConstant(1); Node* const int_true = Int32Constant(1);
Label if_equal(this), if_notequal(this); Label if_equal(this), if_notequal(this);
Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal); Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal);
...@@ -7602,7 +7613,7 @@ Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) { ...@@ -7602,7 +7613,7 @@ Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) {
Node* const result = Node* const result =
SelectConstant(Float64Equal(rhs_float, rhs_float), int_false, SelectConstant(Float64Equal(rhs_float, rhs_float), int_false,
int_true, MachineType::PointerRepresentation()); int_true, MachineRepresentation::kWord32);
var_result.Bind(result); var_result.Bind(result);
Goto(&out); Goto(&out);
} }
...@@ -7871,7 +7882,7 @@ Node* CodeStubAssembler::NumberInc(Node* value) { ...@@ -7871,7 +7882,7 @@ Node* CodeStubAssembler::NumberInc(Node* value) {
Branch(overflow, &if_overflow, &if_notoverflow); Branch(overflow, &if_overflow, &if_notoverflow);
Bind(&if_notoverflow); Bind(&if_notoverflow);
var_result.Bind(Projection(0, pair)); var_result.Bind(BitcastWordToTaggedSigned(Projection(0, pair)));
Goto(&end); Goto(&end);
Bind(&if_overflow); Bind(&if_overflow);
...@@ -8055,7 +8066,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map, ...@@ -8055,7 +8066,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
{ {
Node* map_index = Node* map_index =
IntPtrAdd(IntPtrConstant(kBaseMapIndex + kFastIteratorOffset), IntPtrAdd(IntPtrConstant(kBaseMapIndex + kFastIteratorOffset),
LoadMapElementsKind(array_map)); ChangeUint32ToWord(LoadMapElementsKind(array_map)));
CSA_ASSERT(this, IntPtrGreaterThanOrEqual( CSA_ASSERT(this, IntPtrGreaterThanOrEqual(
map_index, IntPtrConstant(kBaseMapIndex + map_index, IntPtrConstant(kBaseMapIndex +
kFastIteratorOffset))); kFastIteratorOffset)));
...@@ -8083,7 +8094,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map, ...@@ -8083,7 +8094,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
{ {
Node* map_index = Node* map_index =
IntPtrAdd(IntPtrConstant(kBaseMapIndex - UINT8_ELEMENTS), IntPtrAdd(IntPtrConstant(kBaseMapIndex - UINT8_ELEMENTS),
LoadMapElementsKind(array_map)); ChangeUint32ToWord(LoadMapElementsKind(array_map)));
CSA_ASSERT( CSA_ASSERT(
this, IntPtrLessThan(map_index, IntPtrConstant(kBaseMapIndex + this, IntPtrLessThan(map_index, IntPtrConstant(kBaseMapIndex +
kFastIteratorOffset))); kFastIteratorOffset)));
...@@ -8130,27 +8141,19 @@ Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) { ...@@ -8130,27 +8141,19 @@ Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) {
Node* buffer_bit_field = LoadObjectField( Node* buffer_bit_field = LoadObjectField(
buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32());
Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); return IsSetWord32<JSArrayBuffer::WasNeutered>(buffer_bit_field);
return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask),
Int32Constant(0));
} }
CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc, CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc)
CodeStubAssembler::ParameterMode mode)
: assembler_(assembler), : assembler_(assembler),
argc_(argc), argc_(argc),
arguments_(nullptr), arguments_(nullptr),
fp_(assembler->LoadFramePointer()) { fp_(assembler->LoadFramePointer()) {
argc_ = assembler->ChangeUint32ToWord(argc_);
Node* offset = assembler->ElementOffsetFromIndex( Node* offset = assembler->ElementOffsetFromIndex(
argc_, FAST_ELEMENTS, mode, argc_, FAST_ELEMENTS, CodeStubAssembler::INTPTR_PARAMETERS,
(StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize); (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize);
arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset); arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset);
if (mode == CodeStubAssembler::INTEGER_PARAMETERS) {
argc_ = assembler->ChangeInt32ToIntPtr(argc_);
} else if (mode == CodeStubAssembler::SMI_PARAMETERS) {
argc_ = assembler->SmiUntag(argc_);
}
} }
Node* CodeStubArguments::GetReceiver() const { Node* CodeStubArguments::GetReceiver() const {
...@@ -8227,7 +8230,7 @@ Node* CodeStubAssembler::IsDebugActive() { ...@@ -8227,7 +8230,7 @@ Node* CodeStubAssembler::IsDebugActive() {
Node* is_debug_active = Load( Node* is_debug_active = Load(
MachineType::Uint8(), MachineType::Uint8(),
ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); ExternalConstant(ExternalReference::debug_is_active_address(isolate())));
return WordNotEqual(is_debug_active, Int32Constant(0)); return Word32NotEqual(is_debug_active, Int32Constant(0));
} }
Node* CodeStubAssembler::IsPromiseHookEnabled() { Node* CodeStubAssembler::IsPromiseHookEnabled() {
...@@ -8235,7 +8238,7 @@ Node* CodeStubAssembler::IsPromiseHookEnabled() { ...@@ -8235,7 +8238,7 @@ Node* CodeStubAssembler::IsPromiseHookEnabled() {
Load(MachineType::Uint8(), Load(MachineType::Uint8(),
ExternalConstant( ExternalConstant(
ExternalReference::is_promisehook_enabled_address(isolate()))); ExternalReference::is_promisehook_enabled_address(isolate())));
return WordNotEqual(is_promisehook_enabled, Int32Constant(0)); return Word32NotEqual(is_promisehook_enabled, Int32Constant(0));
} }
Node* CodeStubAssembler::AllocateJSPromise(Node* context) { Node* CodeStubAssembler::AllocateJSPromise(Node* context) {
......
...@@ -85,16 +85,26 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -85,16 +85,26 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
: MachineRepresentation::kTaggedSigned; : MachineRepresentation::kTaggedSigned;
} }
Node* UntagParameter(Node* value, ParameterMode mode) { Node* ParameterToWord(Node* value, ParameterMode mode) {
if (mode != SMI_PARAMETERS) value = SmiUntag(value); if (mode == SMI_PARAMETERS) value = SmiUntag(value);
return value; return value;
} }
Node* TagParameter(Node* value, ParameterMode mode) { Node* WordToParameter(Node* value, ParameterMode mode) {
if (mode == SMI_PARAMETERS) value = SmiTag(value);
return value;
}
Node* ParameterToTagged(Node* value, ParameterMode mode) {
if (mode != SMI_PARAMETERS) value = SmiTag(value); if (mode != SMI_PARAMETERS) value = SmiTag(value);
return value; return value;
} }
Node* TaggedToParameter(Node* value, ParameterMode mode) {
if (mode != SMI_PARAMETERS) value = SmiUntag(value);
return value;
}
#define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName, Int32OpName) \ #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName, Int32OpName) \
Node* OpName(Node* a, Node* b, ParameterMode mode) { \ Node* OpName(Node* a, Node* b, ParameterMode mode) { \
if (mode == SMI_PARAMETERS) { \ if (mode == SMI_PARAMETERS) { \
...@@ -111,6 +121,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -111,6 +121,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Int32LessThan) Int32LessThan)
PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan, PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan,
Int32GreaterThan) Int32GreaterThan)
PARAMETER_BINOP(IntPtrOrSmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual,
SmiGreaterThanOrEqual, Int32GreaterThanOrEqual)
PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow, PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow,
Uint32LessThan) Uint32LessThan)
PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual, PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual,
...@@ -190,6 +202,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -190,6 +202,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan) SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan)
SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual) SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual)
SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan) SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan)
SMI_COMPARISON_OP(SmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual)
#undef SMI_COMPARISON_OP #undef SMI_COMPARISON_OP
Node* SmiMax(Node* a, Node* b); Node* SmiMax(Node* a, Node* b);
Node* SmiMin(Node* a, Node* b); Node* SmiMin(Node* a, Node* b);
...@@ -759,13 +772,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -759,13 +772,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// Returns true if any of the |T|'s bits in given |word| are set. // Returns true if any of the |T|'s bits in given |word| are set.
template <typename T> template <typename T>
Node* IsSetWord(Node* word) { Node* IsSetWord(Node* word) {
return WordNotEqual(WordAnd(word, IntPtrConstant(T::kMask)), return IsSetWord(word, T::kMask);
IntPtrConstant(0));
} }
// Returns true if any of the mask's bits in given |word| are set. // Returns true if any of the mask's bits in given |word| are set.
Node* IsSetWord(Node* word, uint32_t mask) { Node* IsSetWord(Node* word, uint32_t mask) {
return WordNotEqual(WordAnd(word, Int32Constant(mask)), Int32Constant(0)); return WordNotEqual(WordAnd(word, IntPtrConstant(mask)), IntPtrConstant(0));
} }
void SetCounter(StatsCounter* counter, int value); void SetCounter(StatsCounter* counter, int value);
...@@ -1141,11 +1153,9 @@ class CodeStubArguments { ...@@ -1141,11 +1153,9 @@ class CodeStubArguments {
public: public:
typedef compiler::Node Node; typedef compiler::Node Node;
// |argc| specifies the number of arguments passed to the builtin excluding // |argc| is an uint32 value which specifies the number of arguments passed
// the receiver. // to the builtin excluding the receiver.
CodeStubArguments(CodeStubAssembler* assembler, Node* argc, CodeStubArguments(CodeStubAssembler* assembler, Node* argc);
CodeStubAssembler::ParameterMode mode =
CodeStubAssembler::INTPTR_PARAMETERS);
Node* GetReceiver() const; Node* GetReceiver() const;
......
...@@ -2742,7 +2742,7 @@ compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler, ...@@ -2742,7 +2742,7 @@ compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler,
ParameterMode param_mode = assembler->OptimalParameterMode(); ParameterMode param_mode = assembler->OptimalParameterMode();
Node* length = assembler->LoadJSArrayLength(boilerplate); Node* length = assembler->LoadJSArrayLength(boilerplate);
capacity = assembler->UntagParameter(capacity, param_mode); capacity = assembler->TaggedToParameter(capacity, param_mode);
Node *array, *elements; Node *array, *elements;
std::tie(array, elements) = std::tie(array, elements) =
...@@ -2760,7 +2760,7 @@ compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler, ...@@ -2760,7 +2760,7 @@ compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler,
assembler->LoadObjectField(boilerplate_elements, offset)); assembler->LoadObjectField(boilerplate_elements, offset));
} }
length = assembler->UntagParameter(length, param_mode); length = assembler->TaggedToParameter(length, param_mode);
assembler->Comment("copy boilerplate elements"); assembler->Comment("copy boilerplate elements");
assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements, assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements,
......
...@@ -1984,7 +1984,8 @@ void InstructionSelector::VisitReturn(Node* ret) { ...@@ -1984,7 +1984,8 @@ void InstructionSelector::VisitReturn(Node* ret) {
DCHECK_GE(input_count, 1); DCHECK_GE(input_count, 1);
auto value_locations = zone()->NewArray<InstructionOperand>(input_count); auto value_locations = zone()->NewArray<InstructionOperand>(input_count);
Node* pop_count = ret->InputAt(0); Node* pop_count = ret->InputAt(0);
value_locations[0] = pop_count->opcode() == IrOpcode::kInt32Constant value_locations[0] = (pop_count->opcode() == IrOpcode::kInt32Constant ||
pop_count->opcode() == IrOpcode::kInt64Constant)
? g.UseImmediate(pop_count) ? g.UseImmediate(pop_count)
: g.UseRegister(pop_count); : g.UseRegister(pop_count);
for (int i = 1; i < input_count; ++i) { for (int i = 1; i < input_count; ++i) {
......
...@@ -30,6 +30,10 @@ class MachineRepresentationInferrer { ...@@ -30,6 +30,10 @@ class MachineRepresentationInferrer {
Run(); Run();
} }
CallDescriptor* call_descriptor() const {
return linkage_->GetIncomingDescriptor();
}
MachineRepresentation GetRepresentation(Node const* node) const { MachineRepresentation GetRepresentation(Node const* node) const {
return representation_vector_.at(node->id()); return representation_vector_.at(node->id());
} }
...@@ -94,6 +98,11 @@ class MachineRepresentationInferrer { ...@@ -94,6 +98,11 @@ class MachineRepresentationInferrer {
linkage_->GetParameterType(ParameterIndexOf(node->op())) linkage_->GetParameterType(ParameterIndexOf(node->op()))
.representation(); .representation();
break; break;
case IrOpcode::kReturn: {
representation_vector_[node->id()] = PromoteRepresentation(
linkage_->GetReturnType().representation());
break;
}
case IrOpcode::kProjection: { case IrOpcode::kProjection: {
representation_vector_[node->id()] = GetProjectionType(node); representation_vector_[node->id()] = GetProjectionType(node);
} break; } break;
...@@ -136,6 +145,9 @@ class MachineRepresentationInferrer { ...@@ -136,6 +145,9 @@ class MachineRepresentationInferrer {
break; break;
} }
case IrOpcode::kAtomicStore: case IrOpcode::kAtomicStore:
representation_vector_[node->id()] =
PromoteRepresentation(AtomicStoreRepresentationOf(node->op()));
break;
case IrOpcode::kStore: case IrOpcode::kStore:
case IrOpcode::kProtectedStore: case IrOpcode::kProtectedStore:
representation_vector_[node->id()] = PromoteRepresentation( representation_vector_[node->id()] = PromoteRepresentation(
...@@ -456,6 +468,11 @@ class MachineRepresentationChecker { ...@@ -456,6 +468,11 @@ class MachineRepresentationChecker {
CheckValueInputIsTagged(node, i); CheckValueInputIsTagged(node, i);
} }
break; break;
case MachineRepresentation::kWord32:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
CheckValueInputForInt32Op(node, i);
}
break;
default: default:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) { for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
CheckValueInputRepresentationIs( CheckValueInputRepresentationIs(
...@@ -468,10 +485,33 @@ class MachineRepresentationChecker { ...@@ -468,10 +485,33 @@ class MachineRepresentationChecker {
case IrOpcode::kSwitch: case IrOpcode::kSwitch:
CheckValueInputForInt32Op(node, 0); CheckValueInputForInt32Op(node, 0);
break; break;
case IrOpcode::kReturn: case IrOpcode::kReturn: {
// TODO(epertoso): use the linkage to determine which tipe we // TODO(ishell): enable once the pop count parameter type becomes
// should have here. // MachineType::PointerRepresentation(). Currently it's int32 or
// word-size.
// CheckValueInputRepresentationIs(
// node, 0, MachineType::PointerRepresentation()); // Pop count
size_t return_count = inferrer_->call_descriptor()->ReturnCount();
for (size_t i = 0; i < return_count; i++) {
MachineType type = inferrer_->call_descriptor()->GetReturnType(i);
int input_index = static_cast<int>(i + 1);
switch (type.representation()) {
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTaggedSigned:
CheckValueInputIsTagged(node, input_index);
break;
case MachineRepresentation::kWord32:
CheckValueInputForInt32Op(node, input_index);
break;
default:
CheckValueInputRepresentationIs(
node, 2, inferrer_->GetRepresentation(node));
}
break;
}
break; break;
}
case IrOpcode::kTypedStateValues: case IrOpcode::kTypedStateValues:
case IrOpcode::kFrameState: case IrOpcode::kFrameState:
break; break;
......
...@@ -879,9 +879,7 @@ void AccessorAssemblerImpl::EmitElementLoad( ...@@ -879,9 +879,7 @@ void AccessorAssemblerImpl::EmitElementLoad(
Comment("typed elements"); Comment("typed elements");
// Check if buffer has been neutered. // Check if buffer has been neutered.
Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset); Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset);
Node* bitfield = LoadObjectField(buffer, JSArrayBuffer::kBitFieldOffset, GotoIf(IsDetachedBuffer(buffer), miss);
MachineType::Uint32());
GotoIf(IsSetWord32<JSArrayBuffer::WasNeutered>(bitfield), miss);
// Bounds check. // Bounds check.
Node* length = Node* length =
...@@ -893,9 +891,9 @@ void AccessorAssemblerImpl::EmitElementLoad( ...@@ -893,9 +891,9 @@ void AccessorAssemblerImpl::EmitElementLoad(
LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset, LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset,
MachineType::Pointer()); MachineType::Pointer());
Node* base_pointer = Node* base_pointer =
LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset, LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset);
MachineType::Pointer()); Node* backing_store =
Node* backing_store = IntPtrAdd(external_pointer, base_pointer); IntPtrAdd(external_pointer, BitcastTaggedToWord(base_pointer));
Label uint8_elements(this), int8_elements(this), uint16_elements(this), Label uint8_elements(this), int8_elements(this), uint16_elements(this),
int16_elements(this), uint32_elements(this), int32_elements(this), int16_elements(this), uint32_elements(this), int32_elements(this),
......
...@@ -402,9 +402,9 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformIndependent( ...@@ -402,9 +402,9 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformIndependent(
void BuiltinDescriptor::InitializePlatformIndependent( void BuiltinDescriptor::InitializePlatformIndependent(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
MachineType machine_types[] = {MachineType::AnyTagged(), // kTarget, kNewTarget, kArgumentsCount
MachineType::AnyTagged(), MachineType machine_types[] = {
MachineType::Pointer()}; MachineType::AnyTagged(), MachineType::AnyTagged(), MachineType::Int32()};
data->InitializePlatformIndependent(arraysize(machine_types), 0, data->InitializePlatformIndependent(arraysize(machine_types), 0,
machine_types); machine_types);
} }
......
...@@ -616,6 +616,7 @@ SIMD128_TYPES(SIMD128_ALLOC_DESC) ...@@ -616,6 +616,7 @@ SIMD128_TYPES(SIMD128_ALLOC_DESC)
class BuiltinDescriptor : public CallInterfaceDescriptor { class BuiltinDescriptor : public CallInterfaceDescriptor {
public: public:
// TODO(ishell): Where is kFunction??
DEFINE_PARAMETERS(kNewTarget, kArgumentsCount) DEFINE_PARAMETERS(kNewTarget, kArgumentsCount)
DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(BuiltinDescriptor, DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(BuiltinDescriptor,
CallInterfaceDescriptor) CallInterfaceDescriptor)
......
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