Commit 0caf1d20 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[csa] Add C++ compile time type checks to CSA.

Bug: 
Cq-Include-Trybots: master.tryserver.v8:v8_linux_noi18n_rel_ng
Change-Id: I2e1b36303f8b9ad4a3dc4e488123e6e4ce8b02ec
Reviewed-on: https://chromium-review.googlesource.com/533033
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47149}
parent 9735d7f1
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/base/utils/random-number-generator.h" #include "src/base/utils/random-number-generator.h"
#include "src/codegen.h" #include "src/codegen.h"
#include "src/compiler/code-assembler.h"
#include "src/counters.h" #include "src/counters.h"
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
...@@ -1510,6 +1511,10 @@ ExternalReference ExternalReference::try_internalize_string_function( ...@@ -1510,6 +1511,10 @@ ExternalReference ExternalReference::try_internalize_string_function(
isolate, FUNCTION_ADDR(StringTable::LookupStringIfExists_NoAllocate))); isolate, FUNCTION_ADDR(StringTable::LookupStringIfExists_NoAllocate)));
} }
ExternalReference ExternalReference::check_object_type(Isolate* isolate) {
return ExternalReference(Redirect(isolate, FUNCTION_ADDR(CheckObjectType)));
}
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
ExternalReference ExternalReference::intl_convert_one_byte_to_lower( ExternalReference ExternalReference::intl_convert_one_byte_to_lower(
Isolate* isolate) { Isolate* isolate) {
......
...@@ -986,6 +986,8 @@ class ExternalReference BASE_EMBEDDED { ...@@ -986,6 +986,8 @@ class ExternalReference BASE_EMBEDDED {
static ExternalReference try_internalize_string_function(Isolate* isolate); static ExternalReference try_internalize_string_function(Isolate* isolate);
static ExternalReference check_object_type(Isolate* isolate);
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
static ExternalReference intl_convert_one_byte_to_lower(Isolate* isolate); static ExternalReference intl_convert_one_byte_to_lower(Isolate* isolate);
static ExternalReference intl_to_latin1_lower_table(Isolate* isolate); static ExternalReference intl_to_latin1_lower_table(Isolate* isolate);
......
...@@ -55,6 +55,13 @@ std::unique_ptr<T> make_unique(Args&&... args) { ...@@ -55,6 +55,13 @@ std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
} }
// implicit_cast<A>(x) triggers an implicit cast from {x} to type {A}. This is
// useful in situations where static_cast<A>(x) would do too much.
template <class A>
A implicit_cast(A x) {
return x;
}
} // namespace base } // namespace base
} // namespace v8 } // namespace v8
......
...@@ -145,7 +145,7 @@ Node* ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs( ...@@ -145,7 +145,7 @@ Node* ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs(
[this, elements, &offset](Node* arg) { [this, elements, &offset](Node* arg) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, StoreNoWriteBarrier(MachineRepresentation::kTagged,
elements, offset.value(), arg); elements, offset.value(), arg);
Increment(offset, kPointerSize); Increment(&offset, kPointerSize);
}, },
first_arg, nullptr, param_mode); first_arg, nullptr, param_mode);
return result; return result;
...@@ -332,7 +332,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -332,7 +332,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
mapped_offset = BuildFastLoop( mapped_offset = BuildFastLoop(
var_list1, argument_offset, mapped_offset, var_list1, argument_offset, mapped_offset,
[this, elements, &current_argument](Node* offset) { [this, elements, &current_argument](Node* offset) {
Increment(current_argument, kPointerSize); Increment(&current_argument, kPointerSize);
Node* arg = LoadBufferObject(current_argument.value(), 0); Node* arg = LoadBufferObject(current_argument.value(), 0);
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, offset,
arg); arg);
...@@ -370,7 +370,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -370,7 +370,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
StoreNoWriteBarrier( StoreNoWriteBarrier(
MachineRepresentation::kTagged, adjusted_map_array, MachineRepresentation::kTagged, adjusted_map_array,
offset, ParameterToTagged(context_index.value(), mode)); offset, ParameterToTagged(context_index.value(), mode));
Increment(context_index, 1, mode); Increment(&context_index, 1, mode);
}, },
-kPointerSize, INTPTR_PARAMETERS); -kPointerSize, INTPTR_PARAMETERS);
......
This diff is collapsed.
...@@ -699,8 +699,8 @@ TF_BUILTIN(OrderedHashTableHealIndex, CollectionsBuiltinsAssembler) { ...@@ -699,8 +699,8 @@ TF_BUILTIN(OrderedHashTableHealIndex, CollectionsBuiltinsAssembler) {
Node* removed_index = LoadFixedArrayElement( Node* removed_index = LoadFixedArrayElement(
table, i, OrderedHashTableBase::kRemovedHolesIndex * kPointerSize); table, i, OrderedHashTableBase::kRemovedHolesIndex * kPointerSize);
GotoIf(SmiGreaterThanOrEqual(removed_index, index), &return_index); GotoIf(SmiGreaterThanOrEqual(removed_index, index), &return_index);
Decrement(var_index, 1, SMI_PARAMETERS); Decrement(&var_index, 1, SMI_PARAMETERS);
Increment(var_i); Increment(&var_i);
Goto(&loop); Goto(&loop);
} }
...@@ -792,7 +792,7 @@ std::tuple<Node*, Node*, Node*> CollectionsBuiltinsAssembler::NextSkipHoles( ...@@ -792,7 +792,7 @@ std::tuple<Node*, Node*, Node*> CollectionsBuiltinsAssembler::NextSkipHoles(
entry_key = entry_key =
LoadFixedArrayElement(table, entry_start_position, LoadFixedArrayElement(table, entry_start_position,
TableType::kHashTableStartIndex * kPointerSize); TableType::kHashTableStartIndex * kPointerSize);
Increment(var_index); Increment(&var_index);
Branch(IsTheHole(entry_key), &loop, &done_loop); Branch(IsTheHole(entry_key), &loop, &done_loop);
} }
...@@ -898,7 +898,7 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) { ...@@ -898,7 +898,7 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) {
// Otherwise, go to runtime to compute the hash code. // Otherwise, go to runtime to compute the hash code.
entry_start_position_or_hash.Bind( entry_start_position_or_hash.Bind(
SmiUntag(CallRuntime(Runtime::kGenericHash, context, key))); SmiUntag(CAST(CallRuntime(Runtime::kGenericHash, context, key))));
Goto(&add_entry); Goto(&add_entry);
} }
...@@ -914,9 +914,9 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) { ...@@ -914,9 +914,9 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) {
STATIC_ASSERT(OrderedHashMap::kLoadFactor == 2); STATIC_ASSERT(OrderedHashMap::kLoadFactor == 2);
Node* const capacity = WordShl(number_of_buckets.value(), 1); Node* const capacity = WordShl(number_of_buckets.value(), 1);
Node* const number_of_elements = SmiUntag( Node* const number_of_elements = SmiUntag(
LoadObjectField(table, OrderedHashMap::kNumberOfElementsOffset)); CAST(LoadObjectField(table, OrderedHashMap::kNumberOfElementsOffset)));
Node* const number_of_deleted = SmiUntag( Node* const number_of_deleted = SmiUntag(CAST(LoadObjectField(
LoadObjectField(table, OrderedHashMap::kNumberOfDeletedElementsOffset)); table, OrderedHashMap::kNumberOfDeletedElementsOffset)));
occupancy.Bind(IntPtrAdd(number_of_elements, number_of_deleted)); occupancy.Bind(IntPtrAdd(number_of_elements, number_of_deleted));
GotoIf(IntPtrLessThan(occupancy.value(), capacity), &store_new_entry); GotoIf(IntPtrLessThan(occupancy.value(), capacity), &store_new_entry);
...@@ -926,10 +926,10 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) { ...@@ -926,10 +926,10 @@ TF_BUILTIN(MapSet, CollectionsBuiltinsAssembler) {
table_var.Bind(LoadObjectField(receiver, JSMap::kTableOffset)); table_var.Bind(LoadObjectField(receiver, JSMap::kTableOffset));
number_of_buckets.Bind(SmiUntag(LoadFixedArrayElement( number_of_buckets.Bind(SmiUntag(LoadFixedArrayElement(
table_var.value(), OrderedHashMap::kNumberOfBucketsIndex))); table_var.value(), OrderedHashMap::kNumberOfBucketsIndex)));
Node* const new_number_of_elements = SmiUntag(LoadObjectField( Node* const new_number_of_elements = SmiUntag(CAST(LoadObjectField(
table_var.value(), OrderedHashMap::kNumberOfElementsOffset)); table_var.value(), OrderedHashMap::kNumberOfElementsOffset)));
Node* const new_number_of_deleted = SmiUntag(LoadObjectField( Node* const new_number_of_deleted = SmiUntag(CAST(LoadObjectField(
table_var.value(), OrderedHashMap::kNumberOfDeletedElementsOffset)); table_var.value(), OrderedHashMap::kNumberOfDeletedElementsOffset)));
occupancy.Bind(IntPtrAdd(new_number_of_elements, new_number_of_deleted)); occupancy.Bind(IntPtrAdd(new_number_of_elements, new_number_of_deleted));
Goto(&store_new_entry); Goto(&store_new_entry);
} }
...@@ -1005,14 +1005,15 @@ TF_BUILTIN(MapDelete, CollectionsBuiltinsAssembler) { ...@@ -1005,14 +1005,15 @@ TF_BUILTIN(MapDelete, CollectionsBuiltinsAssembler) {
OrderedHashMap::kValueOffset)); OrderedHashMap::kValueOffset));
// Decrement the number of elements, increment the number of deleted elements. // Decrement the number of elements, increment the number of deleted elements.
Node* const number_of_elements = Node* const number_of_elements = SmiSub(
SmiSub(LoadObjectField(table, OrderedHashMap::kNumberOfElementsOffset), CAST(LoadObjectField(table, OrderedHashMap::kNumberOfElementsOffset)),
SmiConstant(1)); SmiConstant(1));
StoreObjectFieldNoWriteBarrier(table, OrderedHashMap::kNumberOfElementsOffset, StoreObjectFieldNoWriteBarrier(table, OrderedHashMap::kNumberOfElementsOffset,
number_of_elements); number_of_elements);
Node* const number_of_deleted = SmiAdd( Node* const number_of_deleted =
LoadObjectField(table, OrderedHashMap::kNumberOfDeletedElementsOffset), SmiAdd(CAST(LoadObjectField(
SmiConstant(1)); table, OrderedHashMap::kNumberOfDeletedElementsOffset)),
SmiConstant(1));
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
table, OrderedHashMap::kNumberOfDeletedElementsOffset, number_of_deleted); table, OrderedHashMap::kNumberOfDeletedElementsOffset, number_of_deleted);
...@@ -1064,7 +1065,7 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) { ...@@ -1064,7 +1065,7 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) {
// Otherwise, go to runtime to compute the hash code. // Otherwise, go to runtime to compute the hash code.
entry_start_position_or_hash.Bind( entry_start_position_or_hash.Bind(
SmiUntag(CallRuntime(Runtime::kGenericHash, context, key))); SmiUntag(CAST(CallRuntime(Runtime::kGenericHash, context, key))));
Goto(&add_entry); Goto(&add_entry);
} }
...@@ -1080,9 +1081,9 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) { ...@@ -1080,9 +1081,9 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) {
STATIC_ASSERT(OrderedHashSet::kLoadFactor == 2); STATIC_ASSERT(OrderedHashSet::kLoadFactor == 2);
Node* const capacity = WordShl(number_of_buckets.value(), 1); Node* const capacity = WordShl(number_of_buckets.value(), 1);
Node* const number_of_elements = SmiUntag( Node* const number_of_elements = SmiUntag(
LoadObjectField(table, OrderedHashSet::kNumberOfElementsOffset)); CAST(LoadObjectField(table, OrderedHashSet::kNumberOfElementsOffset)));
Node* const number_of_deleted = SmiUntag( Node* const number_of_deleted = SmiUntag(CAST(LoadObjectField(
LoadObjectField(table, OrderedHashSet::kNumberOfDeletedElementsOffset)); table, OrderedHashSet::kNumberOfDeletedElementsOffset)));
occupancy.Bind(IntPtrAdd(number_of_elements, number_of_deleted)); occupancy.Bind(IntPtrAdd(number_of_elements, number_of_deleted));
GotoIf(IntPtrLessThan(occupancy.value(), capacity), &store_new_entry); GotoIf(IntPtrLessThan(occupancy.value(), capacity), &store_new_entry);
...@@ -1092,10 +1093,10 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) { ...@@ -1092,10 +1093,10 @@ TF_BUILTIN(SetAdd, CollectionsBuiltinsAssembler) {
table_var.Bind(LoadObjectField(receiver, JSMap::kTableOffset)); table_var.Bind(LoadObjectField(receiver, JSMap::kTableOffset));
number_of_buckets.Bind(SmiUntag(LoadFixedArrayElement( number_of_buckets.Bind(SmiUntag(LoadFixedArrayElement(
table_var.value(), OrderedHashSet::kNumberOfBucketsIndex))); table_var.value(), OrderedHashSet::kNumberOfBucketsIndex)));
Node* const new_number_of_elements = SmiUntag(LoadObjectField( Node* const new_number_of_elements = SmiUntag(CAST(LoadObjectField(
table_var.value(), OrderedHashSet::kNumberOfElementsOffset)); table_var.value(), OrderedHashSet::kNumberOfElementsOffset)));
Node* const new_number_of_deleted = SmiUntag(LoadObjectField( Node* const new_number_of_deleted = SmiUntag(CAST(LoadObjectField(
table_var.value(), OrderedHashSet::kNumberOfDeletedElementsOffset)); table_var.value(), OrderedHashSet::kNumberOfDeletedElementsOffset)));
occupancy.Bind(IntPtrAdd(new_number_of_elements, new_number_of_deleted)); occupancy.Bind(IntPtrAdd(new_number_of_elements, new_number_of_deleted));
Goto(&store_new_entry); Goto(&store_new_entry);
} }
...@@ -1164,14 +1165,15 @@ TF_BUILTIN(SetDelete, CollectionsBuiltinsAssembler) { ...@@ -1164,14 +1165,15 @@ TF_BUILTIN(SetDelete, CollectionsBuiltinsAssembler) {
kPointerSize * OrderedHashSet::kHashTableStartIndex); kPointerSize * OrderedHashSet::kHashTableStartIndex);
// Decrement the number of elements, increment the number of deleted elements. // Decrement the number of elements, increment the number of deleted elements.
Node* const number_of_elements = Node* const number_of_elements = SmiSub(
SmiSub(LoadObjectField(table, OrderedHashSet::kNumberOfElementsOffset), CAST(LoadObjectField(table, OrderedHashSet::kNumberOfElementsOffset)),
SmiConstant(1)); SmiConstant(1));
StoreObjectFieldNoWriteBarrier(table, OrderedHashSet::kNumberOfElementsOffset, StoreObjectFieldNoWriteBarrier(table, OrderedHashSet::kNumberOfElementsOffset,
number_of_elements); number_of_elements);
Node* const number_of_deleted = SmiAdd( Node* const number_of_deleted =
LoadObjectField(table, OrderedHashSet::kNumberOfDeletedElementsOffset), SmiAdd(CAST(LoadObjectField(
SmiConstant(1)); table, OrderedHashSet::kNumberOfDeletedElementsOffset)),
SmiConstant(1));
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
table, OrderedHashSet::kNumberOfDeletedElementsOffset, number_of_deleted); table, OrderedHashSet::kNumberOfDeletedElementsOffset, number_of_deleted);
...@@ -1648,7 +1650,7 @@ TF_BUILTIN(WeakMapLookupHashIndex, CollectionsBuiltinsAssembler) { ...@@ -1648,7 +1650,7 @@ TF_BUILTIN(WeakMapLookupHashIndex, CollectionsBuiltinsAssembler) {
GotoIf(WordEqual(current, key), &if_found); GotoIf(WordEqual(current, key), &if_found);
// See HashTable::NextProbe(). // See HashTable::NextProbe().
Increment(var_count); Increment(&var_count);
entry = WordAnd(IntPtrAdd(entry, var_count.value()), mask); entry = WordAnd(IntPtrAdd(entry, var_count.value()), mask);
var_entry.Bind(entry); var_entry.Bind(entry);
...@@ -1659,7 +1661,7 @@ TF_BUILTIN(WeakMapLookupHashIndex, CollectionsBuiltinsAssembler) { ...@@ -1659,7 +1661,7 @@ TF_BUILTIN(WeakMapLookupHashIndex, CollectionsBuiltinsAssembler) {
Return(SmiConstant(-1)); Return(SmiConstant(-1));
BIND(&if_found); BIND(&if_found);
Return(SmiTag(IntPtrAdd(index, IntPtrConstant(1)))); Return(SmiTag(Signed(IntPtrAdd(index, IntPtrConstant(1)))));
} }
TF_BUILTIN(WeakMapGet, CollectionsBuiltinsAssembler) { TF_BUILTIN(WeakMapGet, CollectionsBuiltinsAssembler) {
......
...@@ -571,9 +571,9 @@ Node* ConstructorBuiltinsAssembler::EmitCreateEmptyArrayLiteral( ...@@ -571,9 +571,9 @@ Node* ConstructorBuiltinsAssembler::EmitCreateEmptyArrayLiteral(
BIND(&create_empty_array); BIND(&create_empty_array);
CSA_ASSERT(this, IsAllocationSite(allocation_site.value())); CSA_ASSERT(this, IsAllocationSite(allocation_site.value()));
Node* kind = SmiToWord32( Node* kind = SmiToWord32(CAST(
LoadObjectField(allocation_site.value(), LoadObjectField(allocation_site.value(),
AllocationSite::kTransitionInfoOrBoilerplateOffset)); AllocationSite::kTransitionInfoOrBoilerplateOffset)));
CSA_ASSERT(this, IsFastElementsKind(kind)); CSA_ASSERT(this, IsFastElementsKind(kind));
Node* native_context = LoadNativeContext(context); Node* native_context = LoadNativeContext(context);
Comment("LoadJSArrayElementsMap"); Comment("LoadJSArrayElementsMap");
......
...@@ -82,7 +82,12 @@ void ForInBuiltinsAssembler::CheckPrototypeEnumCache(Node* receiver, Node* map, ...@@ -82,7 +82,12 @@ void ForInBuiltinsAssembler::CheckPrototypeEnumCache(Node* receiver, Node* map,
BIND(&loop); BIND(&loop);
{ {
Label if_elements(this), if_no_elements(this); Label if_elements(this), if_no_elements(this);
Node* elements = LoadElements(current_js_object.value()); TNode<JSReceiver> receiver = CAST(current_js_object.value());
// The following relies on the elements only aliasing with JSProxy::target,
// which is a Javascript value and hence cannot be confused with an elements
// backing store.
STATIC_ASSERT(JSObject::kElementsOffset == JSProxy::kTargetOffset);
Node* elements = LoadObjectField(receiver, JSObject::kElementsOffset);
Node* empty_fixed_array = LoadRoot(Heap::kEmptyFixedArrayRootIndex); Node* empty_fixed_array = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
// Check that there are no elements. // Check that there are no elements.
Branch(WordEqual(elements, empty_fixed_array), &if_no_elements, Branch(WordEqual(elements, empty_fixed_array), &if_no_elements,
......
...@@ -104,7 +104,8 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) { ...@@ -104,7 +104,8 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
Label empty_arguments(this); Label empty_arguments(this);
Label arguments_done(this, &argument_array); Label arguments_done(this, &argument_array);
GotoIf(Uint32LessThanOrEqual(argc, Int32Constant(1)), &empty_arguments); GotoIf(Uint32LessThanOrEqual(argc, Int32Constant(1)), &empty_arguments);
Node* elements_length = ChangeUint32ToWord(Int32Sub(argc, Int32Constant(1))); Node* elements_length =
ChangeUint32ToWord(Unsigned(Int32Sub(argc, Int32Constant(1))));
Node* elements = AllocateFixedArray(PACKED_ELEMENTS, elements_length); Node* elements = AllocateFixedArray(PACKED_ELEMENTS, elements_length);
VARIABLE(index, MachineType::PointerRepresentation()); VARIABLE(index, MachineType::PointerRepresentation());
index.Bind(IntPtrConstant(0)); index.Bind(IntPtrConstant(0));
...@@ -112,7 +113,7 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) { ...@@ -112,7 +113,7 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
args.ForEach(foreach_vars, args.ForEach(foreach_vars,
[this, elements, &index](Node* arg) { [this, elements, &index](Node* arg) {
StoreFixedArrayElement(elements, index.value(), arg); StoreFixedArrayElement(elements, index.value(), arg);
Increment(index); Increment(&index);
}, },
IntPtrConstant(1)); IntPtrConstant(1));
argument_array.Bind(elements); argument_array.Bind(elements);
......
...@@ -75,7 +75,7 @@ TF_BUILTIN(StringToLowerCaseIntl, IntlBuiltinsAssembler) { ...@@ -75,7 +75,7 @@ TF_BUILTIN(StringToLowerCaseIntl, IntlBuiltinsAssembler) {
var_did_change.Bind(Word32Or(Word32NotEqual(c, lower), var_did_change.Bind(Word32Or(Word32NotEqual(c, lower),
var_did_change.value())); var_did_change.value()));
Increment(var_cursor); Increment(&var_cursor);
}, },
kCharSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); kCharSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
......
...@@ -19,12 +19,15 @@ class MathBuiltinsAssembler : public CodeStubAssembler { ...@@ -19,12 +19,15 @@ class MathBuiltinsAssembler : public CodeStubAssembler {
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
protected: protected:
void MathRoundingOperation(Node* context, Node* x, void MathRoundingOperation(
Node* (CodeStubAssembler::*float64op)(Node*)); Node* context, Node* x,
void MathUnaryOperation(Node* context, Node* x, TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>));
Node* (CodeStubAssembler::*float64op)(Node*)); void MathUnaryOperation(
Node* context, Node* x,
TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>));
void MathMaxMin(Node* context, Node* argc, void MathMaxMin(Node* context, Node* argc,
Node* (CodeStubAssembler::*float64op)(Node*, Node*), TNode<Float64T> (CodeStubAssembler::*float64op)(
SloppyTNode<Float64T>, SloppyTNode<Float64T>),
double default_val); double default_val);
}; };
...@@ -114,7 +117,8 @@ TF_BUILTIN(MathAbs, CodeStubAssembler) { ...@@ -114,7 +117,8 @@ TF_BUILTIN(MathAbs, CodeStubAssembler) {
} }
void MathBuiltinsAssembler::MathRoundingOperation( void MathBuiltinsAssembler::MathRoundingOperation(
Node* context, Node* x, Node* (CodeStubAssembler::*float64op)(Node*)) { Node* context, Node* x,
TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>)) {
// We might need to loop once for ToNumber conversion. // We might need to loop once for ToNumber conversion.
VARIABLE(var_x, MachineRepresentation::kTagged, x); VARIABLE(var_x, MachineRepresentation::kTagged, x);
Label loop(this, &var_x); Label loop(this, &var_x);
...@@ -159,7 +163,8 @@ void MathBuiltinsAssembler::MathRoundingOperation( ...@@ -159,7 +163,8 @@ void MathBuiltinsAssembler::MathRoundingOperation(
} }
void MathBuiltinsAssembler::MathUnaryOperation( void MathBuiltinsAssembler::MathUnaryOperation(
Node* context, Node* x, Node* (CodeStubAssembler::*float64op)(Node*)) { Node* context, Node* x,
TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>)) {
Node* x_value = TruncateTaggedToFloat64(context, x); Node* x_value = TruncateTaggedToFloat64(context, x);
Node* value = (this->*float64op)(x_value); Node* value = (this->*float64op)(x_value);
Node* result = AllocateHeapNumberWithValue(value); Node* result = AllocateHeapNumberWithValue(value);
...@@ -168,7 +173,9 @@ void MathBuiltinsAssembler::MathUnaryOperation( ...@@ -168,7 +173,9 @@ void MathBuiltinsAssembler::MathUnaryOperation(
void MathBuiltinsAssembler::MathMaxMin( void MathBuiltinsAssembler::MathMaxMin(
Node* context, Node* argc, Node* context, Node* argc,
Node* (CodeStubAssembler::*float64op)(Node*, Node*), double default_val) { TNode<Float64T> (CodeStubAssembler::*float64op)(SloppyTNode<Float64T>,
SloppyTNode<Float64T>),
double default_val) {
CodeStubArguments arguments(this, ChangeInt32ToIntPtr(argc)); CodeStubArguments arguments(this, ChangeInt32ToIntPtr(argc));
argc = arguments.GetLength(); argc = arguments.GetLength();
......
...@@ -384,11 +384,11 @@ TF_BUILTIN(ObjectPrototypeToString, ObjectBuiltinsAssembler) { ...@@ -384,11 +384,11 @@ TF_BUILTIN(ObjectPrototypeToString, ObjectBuiltinsAssembler) {
// as the exception is observable. // as the exception is observable.
Node* receiver_is_array = Node* receiver_is_array =
CallRuntime(Runtime::kArrayIsArray, context, receiver); CallRuntime(Runtime::kArrayIsArray, context, receiver);
Node* builtin_tag = SelectTaggedConstant( Node* builtin_tag = SelectTaggedConstant<Object>(
IsTrue(receiver_is_array), LoadRoot(Heap::kArray_stringRootIndex), IsTrue(receiver_is_array), LoadRoot(Heap::kArray_stringRootIndex),
SelectTaggedConstant(IsCallableMap(receiver_map), SelectTaggedConstant<Object>(IsCallableMap(receiver_map),
LoadRoot(Heap::kFunction_stringRootIndex), LoadRoot(Heap::kFunction_stringRootIndex),
LoadRoot(Heap::kObject_stringRootIndex))); LoadRoot(Heap::kObject_stringRootIndex)));
// Lookup the @@toStringTag property on the {receiver}. // Lookup the @@toStringTag property on the {receiver}.
VARIABLE(var_tag, MachineRepresentation::kTagged, VARIABLE(var_tag, MachineRepresentation::kTagged,
......
...@@ -639,7 +639,7 @@ void PromiseBuiltinsAssembler::BranchIfFastPath(Node* native_context, ...@@ -639,7 +639,7 @@ void PromiseBuiltinsAssembler::BranchIfFastPath(Node* native_context,
Node* const initial_proto_initial_map = Node* const initial_proto_initial_map =
LoadContextElement(native_context, Context::PROMISE_PROTOTYPE_MAP_INDEX); LoadContextElement(native_context, Context::PROMISE_PROTOTYPE_MAP_INDEX);
Node* const proto_map = LoadMap(LoadMapPrototype(map)); Node* const proto_map = LoadMap(CAST(LoadMapPrototype(map)));
Node* const proto_has_initialmap = Node* const proto_has_initialmap =
WordEqual(proto_map, initial_proto_initial_map); WordEqual(proto_map, initial_proto_initial_map);
......
...@@ -104,7 +104,7 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler { ...@@ -104,7 +104,7 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler {
args.ForEach(list, [this, elements, &index](Node* arg) { args.ForEach(list, [this, elements, &index](Node* arg) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, StoreNoWriteBarrier(MachineRepresentation::kTagged, elements,
index.value(), arg); index.value(), arg);
Increment(index, kPointerSize); Increment(&index, kPointerSize);
}); });
return array; return array;
} }
......
...@@ -75,7 +75,7 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo( ...@@ -75,7 +75,7 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
Label named_captures(this), out(this); Label named_captures(this), out(this);
Node* const num_indices = SmiUntag(LoadFixedArrayElement( TNode<IntPtrT> num_indices = SmiUntag(LoadFixedArrayElement(
match_info, RegExpMatchInfo::kNumberOfCapturesIndex)); match_info, RegExpMatchInfo::kNumberOfCapturesIndex));
Node* const num_results = SmiTag(WordShr(num_indices, 1)); Node* const num_results = SmiTag(WordShr(num_indices, 1));
Node* const start = Node* const start =
...@@ -525,7 +525,7 @@ Node* RegExpBuiltinsAssembler::RegExpExecInternal(Node* const context, ...@@ -525,7 +525,7 @@ Node* RegExpBuiltinsAssembler::RegExpExecInternal(Node* const context,
Node* const smi_value = SmiFromWord32(value); Node* const smi_value = SmiFromWord32(value);
StoreNoWriteBarrier(MachineRepresentation::kTagged, match_info, StoreNoWriteBarrier(MachineRepresentation::kTagged, match_info,
var_to_offset.value(), smi_value); var_to_offset.value(), smi_value);
Increment(var_to_offset, kPointerSize); Increment(&var_to_offset, kPointerSize);
}, },
kInt32Size, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); kInt32Size, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
} }
...@@ -822,7 +822,7 @@ void RegExpBuiltinsAssembler::BranchIfFastRegExp(Node* const context, ...@@ -822,7 +822,7 @@ void RegExpBuiltinsAssembler::BranchIfFastRegExp(Node* const context,
Node* const initial_proto_initial_map = Node* const initial_proto_initial_map =
LoadContextElement(native_context, Context::REGEXP_PROTOTYPE_MAP_INDEX); LoadContextElement(native_context, Context::REGEXP_PROTOTYPE_MAP_INDEX);
Node* const proto_map = LoadMap(LoadMapPrototype(map)); Node* const proto_map = LoadMap(CAST(LoadMapPrototype(map)));
Node* const proto_has_initialmap = Node* const proto_has_initialmap =
WordEqual(proto_map, initial_proto_initial_map); WordEqual(proto_map, initial_proto_initial_map);
...@@ -1147,16 +1147,16 @@ Node* RegExpBuiltinsAssembler::RegExpInitialize(Node* const context, ...@@ -1147,16 +1147,16 @@ Node* RegExpBuiltinsAssembler::RegExpInitialize(Node* const context,
CSA_ASSERT(this, IsJSRegExp(regexp)); CSA_ASSERT(this, IsJSRegExp(regexp));
// Normalize pattern. // Normalize pattern.
Node* const pattern = Node* const pattern = Select<Object>(
Select(IsUndefined(maybe_pattern), [=] { return EmptyStringConstant(); }, IsUndefined(maybe_pattern), [=] { return EmptyStringConstant(); },
[=] { return ToString_Inline(context, maybe_pattern); }, [=] { return ToString_Inline(context, maybe_pattern); },
MachineRepresentation::kTagged); MachineRepresentation::kTagged);
// Normalize flags. // Normalize flags.
Node* const flags = Node* const flags = Select<Object>(
Select(IsUndefined(maybe_flags), [=] { return EmptyStringConstant(); }, IsUndefined(maybe_flags), [=] { return EmptyStringConstant(); },
[=] { return ToString_Inline(context, maybe_flags); }, [=] { return ToString_Inline(context, maybe_flags); },
MachineRepresentation::kTagged); MachineRepresentation::kTagged);
// Initialize. // Initialize.
...@@ -1868,7 +1868,8 @@ class GrowableFixedArray { ...@@ -1868,7 +1868,8 @@ class GrowableFixedArray {
var_length_.Bind(a->IntPtrConstant(0)); var_length_.Bind(a->IntPtrConstant(0));
} }
Node* NewCapacity(CodeStubAssembler* a, Node* const current_capacity) { Node* NewCapacity(CodeStubAssembler* a,
compiler::SloppyTNode<IntPtrT> current_capacity) {
CSA_ASSERT(a, a->IntPtrGreaterThan(current_capacity, a->IntPtrConstant(0))); CSA_ASSERT(a, a->IntPtrGreaterThan(current_capacity, a->IntPtrConstant(0)));
// Growth rate is analog to JSObject::NewElementsCapacity: // Growth rate is analog to JSObject::NewElementsCapacity:
...@@ -2672,10 +2673,10 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath( ...@@ -2672,10 +2673,10 @@ Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
BIND(&if_ispositive); BIND(&if_ispositive);
{ {
Node* const int_elem = SmiUntag(elem); TNode<IntPtrT> int_elem = SmiUntag(elem);
Node* const new_match_start = TNode<IntPtrT> new_match_start =
IntPtrAdd(WordShr(int_elem, IntPtrConstant(11)), Signed(IntPtrAdd(WordShr(int_elem, IntPtrConstant(11)),
WordAnd(int_elem, IntPtrConstant(0x7ff))); WordAnd(int_elem, IntPtrConstant(0x7ff))));
var_match_start.Bind(SmiTag(new_match_start)); var_match_start.Bind(SmiTag(new_match_start));
Goto(&loop_epilogue); Goto(&loop_epilogue);
} }
......
...@@ -57,8 +57,7 @@ void SharedArrayBufferBuiltinsAssembler::ValidateSharedTypedArray( ...@@ -57,8 +57,7 @@ void SharedArrayBufferBuiltinsAssembler::ValidateSharedTypedArray(
GotoIfNot(IsSetWord32<JSArrayBuffer::IsShared>(bitfield), &invalid); GotoIfNot(IsSetWord32<JSArrayBuffer::IsShared>(bitfield), &invalid);
// Fail if the array's element type is float32, float64 or clamped. // Fail if the array's element type is float32, float64 or clamped.
Node* elements_instance_type = Node* elements_instance_type = LoadInstanceType(LoadElements(tagged));
LoadInstanceType(LoadObjectField(tagged, JSObject::kElementsOffset));
STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
......
...@@ -15,6 +15,8 @@ namespace internal { ...@@ -15,6 +15,8 @@ namespace internal {
typedef CodeStubAssembler::RelationalComparisonMode RelationalComparisonMode; typedef CodeStubAssembler::RelationalComparisonMode RelationalComparisonMode;
typedef compiler::Node Node; typedef compiler::Node Node;
template <class A>
using TNode = compiler::TNode<A>;
Node* StringBuiltinsAssembler::DirectStringData(Node* string, Node* StringBuiltinsAssembler::DirectStringData(Node* string,
Node* string_instance_type) { Node* string_instance_type) {
...@@ -124,9 +126,9 @@ Node* StringBuiltinsAssembler::PointerToStringDataAtIndex( ...@@ -124,9 +126,9 @@ Node* StringBuiltinsAssembler::PointerToStringDataAtIndex(
void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument( void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument(
Node* context, Variable* var_start, Node* start, Node* string_length) { Node* context, Variable* var_start, Node* start, Node* string_length) {
Node* const start_int = TNode<Object> const start_int =
ToInteger(context, start, CodeStubAssembler::kTruncateMinusZero); ToInteger(context, start, CodeStubAssembler::kTruncateMinusZero);
Node* const zero = SmiConstant(0); TNode<Smi> const zero = SmiConstant(0);
Label done(this); Label done(this);
Label if_issmi(this), if_isheapnumber(this, Label::kDeferred); Label if_issmi(this), if_isheapnumber(this, Label::kDeferred);
...@@ -134,10 +136,11 @@ void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument( ...@@ -134,10 +136,11 @@ void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument(
BIND(&if_issmi); BIND(&if_issmi);
{ {
var_start->Bind( TNode<Smi> const start_int_smi = CAST(start_int);
Select(SmiLessThan(start_int, zero), var_start->Bind(Select(
[&] { return SmiMax(SmiAdd(string_length, start_int), zero); }, SmiLessThan(start_int_smi, zero),
[&] { return start_int; }, MachineRepresentation::kTagged)); [&] { return SmiMax(SmiAdd(string_length, start_int_smi), zero); },
[&] { return start_int_smi; }, MachineRepresentation::kTagged));
Goto(&done); Goto(&done);
} }
...@@ -147,9 +150,10 @@ void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument( ...@@ -147,9 +150,10 @@ void StringBuiltinsAssembler::ConvertAndBoundsCheckStartArgument(
// negative, {start} = max({string_length} + {start}),0) = 0'. If it is // negative, {start} = max({string_length} + {start}),0) = 0'. If it is
// positive, set {start} to {string_length} which ultimately results in // positive, set {start} to {string_length} which ultimately results in
// returning an empty string. // returning an empty string.
Node* const float_zero = Float64Constant(0.); TNode<HeapNumber> const start_int_hn = CAST(start_int);
Node* const start_float = LoadHeapNumberValue(start_int); TNode<Float64T> const float_zero = Float64Constant(0.);
var_start->Bind(SelectTaggedConstant( TNode<Float64T> const start_float = LoadHeapNumberValue(start_int_hn);
var_start->Bind(SelectTaggedConstant<Smi>(
Float64LessThan(start_float, float_zero), zero, string_length)); Float64LessThan(start_float, float_zero), zero, string_length));
Goto(&done); Goto(&done);
} }
...@@ -921,8 +925,9 @@ void StringBuiltinsAssembler::StringIndexOf( ...@@ -921,8 +925,9 @@ void StringBuiltinsAssembler::StringIndexOf(
// Simplified version of the runtime call where the types of the arguments // Simplified version of the runtime call where the types of the arguments
// are already known due to type checks in this stub. // are already known due to type checks in this stub.
Comment("Call Runtime Unchecked"); Comment("Call Runtime Unchecked");
Node* result = CallRuntime(Runtime::kStringIndexOfUnchecked, SmiConstant(0), Node* result =
subject_string, search_string, position); CallRuntime(Runtime::kStringIndexOfUnchecked, NoContextConstant(),
subject_string, search_string, position);
f_return(result); f_return(result);
} }
} }
...@@ -1058,7 +1063,7 @@ void StringBuiltinsAssembler::MaybeCallFunctionAtSymbol( ...@@ -1058,7 +1063,7 @@ void StringBuiltinsAssembler::MaybeCallFunctionAtSymbol(
LoadContextElement(native_context, Context::STRING_FUNCTION_INDEX); LoadContextElement(native_context, Context::STRING_FUNCTION_INDEX);
Node* const initial_map = Node* const initial_map =
LoadObjectField(string_fun, JSFunction::kPrototypeOrInitialMapOffset); LoadObjectField(string_fun, JSFunction::kPrototypeOrInitialMapOffset);
Node* const proto_map = LoadMap(LoadMapPrototype(initial_map)); Node* const proto_map = LoadMap(CAST(LoadMapPrototype(initial_map)));
Branch(WordEqual(proto_map, initial_proto_initial_map), &out, &next); Branch(WordEqual(proto_map, initial_proto_initial_map), &out, &next);
...@@ -1335,7 +1340,7 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) { ...@@ -1335,7 +1340,7 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) {
Node* const end = args.GetOptionalArgumentValue(kEnd); Node* const end = args.GetOptionalArgumentValue(kEnd);
Node* const context = Parameter(BuiltinDescriptor::kContext); Node* const context = Parameter(BuiltinDescriptor::kContext);
Node* const smi_zero = SmiConstant(0); TNode<Smi> const smi_zero = SmiConstant(0);
// 1. Let O be ? RequireObjectCoercible(this value). // 1. Let O be ? RequireObjectCoercible(this value).
RequireObjectCoercible(context, receiver, "String.prototype.slice"); RequireObjectCoercible(context, receiver, "String.prototype.slice");
...@@ -1381,8 +1386,8 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) { ...@@ -1381,8 +1386,8 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) {
// returning an empty string. // returning an empty string.
Node* const float_zero = Float64Constant(0.); Node* const float_zero = Float64Constant(0.);
Node* const end_float = LoadHeapNumberValue(end_int); Node* const end_float = LoadHeapNumberValue(end_int);
var_end.Bind(SelectTaggedConstant(Float64LessThan(end_float, float_zero), var_end.Bind(SelectTaggedConstant<Smi>(
smi_zero, length)); Float64LessThan(end_float, float_zero), smi_zero, length));
Goto(&out); Goto(&out);
} }
...@@ -1597,13 +1602,13 @@ TF_BUILTIN(StringPrototypeSubstr, StringBuiltinsAssembler) { ...@@ -1597,13 +1602,13 @@ TF_BUILTIN(StringPrototypeSubstr, StringBuiltinsAssembler) {
} }
} }
compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context, TNode<Smi> StringBuiltinsAssembler::ToSmiBetweenZeroAnd(
Node* value, SloppyTNode<Context> context, SloppyTNode<Object> value,
Node* limit) { SloppyTNode<Smi> limit) {
Label out(this); Label out(this);
VARIABLE(var_result, MachineRepresentation::kTagged); TVARIABLE(Smi, var_result);
Node* const value_int = TNode<Object> const value_int =
this->ToInteger(context, value, CodeStubAssembler::kTruncateMinusZero); this->ToInteger(context, value, CodeStubAssembler::kTruncateMinusZero);
Label if_issmi(this), if_isnotsmi(this, Label::kDeferred); Label if_issmi(this), if_isnotsmi(this, Label::kDeferred);
...@@ -1616,15 +1621,15 @@ compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context, ...@@ -1616,15 +1621,15 @@ compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context,
BIND(&if_isinbounds); BIND(&if_isinbounds);
{ {
var_result.Bind(value_int); var_result = CAST(value_int);
Goto(&out); Goto(&out);
} }
BIND(&if_isoutofbounds); BIND(&if_isoutofbounds);
{ {
Node* const zero = SmiConstant(0); TNode<Smi> const zero = SmiConstant(0);
var_result.Bind( var_result =
SelectTaggedConstant(SmiLessThan(value_int, zero), zero, limit)); SelectTaggedConstant(SmiLessThan(value_int, zero), zero, limit);
Goto(&out); Goto(&out);
} }
} }
...@@ -1632,18 +1637,18 @@ compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context, ...@@ -1632,18 +1637,18 @@ compiler::Node* StringBuiltinsAssembler::ToSmiBetweenZeroAnd(Node* context,
BIND(&if_isnotsmi); BIND(&if_isnotsmi);
{ {
// {value} is a heap number - in this case, it is definitely out of bounds. // {value} is a heap number - in this case, it is definitely out of bounds.
CSA_ASSERT(this, IsHeapNumber(value_int)); TNode<HeapNumber> value_int_hn = CAST(value_int);
Node* const float_zero = Float64Constant(0.); TNode<Float64T> const float_zero = Float64Constant(0.);
Node* const smi_zero = SmiConstant(0); TNode<Smi> const smi_zero = SmiConstant(0);
Node* const value_float = LoadHeapNumberValue(value_int); TNode<Float64T> const value_float = LoadHeapNumberValue(value_int_hn);
var_result.Bind(SelectTaggedConstant( var_result = SelectTaggedConstant(Float64LessThan(value_float, float_zero),
Float64LessThan(value_float, float_zero), smi_zero, limit)); smi_zero, limit);
Goto(&out); Goto(&out);
} }
BIND(&out); BIND(&out);
return var_result.value(); return var_result;
} }
// ES6 #sec-string.prototype.substring // ES6 #sec-string.prototype.substring
...@@ -1748,30 +1753,30 @@ TF_BUILTIN(StringPrototypeIterator, CodeStubAssembler) { ...@@ -1748,30 +1753,30 @@ TF_BUILTIN(StringPrototypeIterator, CodeStubAssembler) {
// Return the |word32| codepoint at {index}. Supports SeqStrings and // Return the |word32| codepoint at {index}. Supports SeqStrings and
// ExternalStrings. // ExternalStrings.
compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt( TNode<Uint32T> StringBuiltinsAssembler::LoadSurrogatePairAt(
compiler::Node* string, compiler::Node* length, compiler::Node* index, SloppyTNode<String> string, SloppyTNode<Smi> length, SloppyTNode<Smi> index,
UnicodeEncoding encoding) { UnicodeEncoding encoding) {
Label handle_surrogate_pair(this), return_result(this); Label handle_surrogate_pair(this), return_result(this);
VARIABLE(var_result, MachineRepresentation::kWord32); TVARIABLE(Uint32T, var_result);
VARIABLE(var_trail, MachineRepresentation::kWord32); TVARIABLE(Uint32T, var_trail);
var_result.Bind(StringCharCodeAt(string, index)); var_result = StringCharCodeAt(string, index);
var_trail.Bind(Int32Constant(0)); var_trail = Unsigned(Int32Constant(0));
GotoIf(Word32NotEqual(Word32And(var_result.value(), Int32Constant(0xFC00)), GotoIf(Word32NotEqual(Word32And(var_result, Int32Constant(0xFC00)),
Int32Constant(0xD800)), Int32Constant(0xD800)),
&return_result); &return_result);
Node* next_index = SmiAdd(index, SmiConstant(1)); TNode<Smi> next_index = SmiAdd(index, SmiConstant(1));
GotoIfNot(SmiLessThan(next_index, length), &return_result); GotoIfNot(SmiLessThan(next_index, length), &return_result);
var_trail.Bind(StringCharCodeAt(string, next_index)); var_trail = StringCharCodeAt(string, next_index);
Branch(Word32Equal(Word32And(var_trail.value(), Int32Constant(0xFC00)), Branch(Word32Equal(Word32And(var_trail, Int32Constant(0xFC00)),
Int32Constant(0xDC00)), Int32Constant(0xDC00)),
&handle_surrogate_pair, &return_result); &handle_surrogate_pair, &return_result);
BIND(&handle_surrogate_pair); BIND(&handle_surrogate_pair);
{ {
Node* lead = var_result.value(); TNode<Uint32T> lead = var_result;
Node* trail = var_trail.value(); TNode<Uint32T> trail = var_trail;
// Check that this path is only taken if a surrogate pair is found // Check that this path is only taken if a surrogate pair is found
CSA_SLOW_ASSERT(this, CSA_SLOW_ASSERT(this,
...@@ -1783,10 +1788,10 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt( ...@@ -1783,10 +1788,10 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt(
switch (encoding) { switch (encoding) {
case UnicodeEncoding::UTF16: case UnicodeEncoding::UTF16:
var_result.Bind(Word32Or( var_result = Unsigned(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
Word32Shl(lead, Int32Constant(16)), trail)); Word32Shl(lead, Int32Constant(16)), trail);
#else #else
Word32Shl(trail, Int32Constant(16)), lead)); Word32Shl(trail, Int32Constant(16)), lead));
#endif #endif
...@@ -1795,12 +1800,12 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt( ...@@ -1795,12 +1800,12 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt(
case UnicodeEncoding::UTF32: { case UnicodeEncoding::UTF32: {
// Convert UTF16 surrogate pair into |word32| code point, encoded as // Convert UTF16 surrogate pair into |word32| code point, encoded as
// UTF32. // UTF32.
Node* surrogate_offset = TNode<Int32T> surrogate_offset =
Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00); Int32Constant(0x10000 - (0xD800 << 10) - 0xDC00);
// (lead << 10) + trail + SURROGATE_OFFSET // (lead << 10) + trail + SURROGATE_OFFSET
var_result.Bind(Int32Add(Word32Shl(lead, Int32Constant(10)), var_result = Unsigned(Int32Add(Word32Shl(lead, Int32Constant(10)),
Int32Add(trail, surrogate_offset))); Int32Add(trail, surrogate_offset)));
break; break;
} }
} }
...@@ -1808,7 +1813,7 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt( ...@@ -1808,7 +1813,7 @@ compiler::Node* StringBuiltinsAssembler::LoadSurrogatePairAt(
} }
BIND(&return_result); BIND(&return_result);
return var_result.value(); return var_result;
} }
// ES6 #sec-%stringiteratorprototype%.next // ES6 #sec-%stringiteratorprototype%.next
......
...@@ -49,10 +49,14 @@ class StringBuiltinsAssembler : public CodeStubAssembler { ...@@ -49,10 +49,14 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
Node* right, Node* right,
RelationalComparisonMode mode); RelationalComparisonMode mode);
Node* ToSmiBetweenZeroAnd(Node* context, Node* value, Node* limit); TNode<Smi> ToSmiBetweenZeroAnd(SloppyTNode<Context> context,
SloppyTNode<Object> value,
Node* LoadSurrogatePairAt(Node* string, Node* length, Node* index, SloppyTNode<Smi> limit);
UnicodeEncoding encoding);
TNode<Uint32T> LoadSurrogatePairAt(SloppyTNode<String> string,
SloppyTNode<Smi> length,
SloppyTNode<Smi> index,
UnicodeEncoding encoding);
void StringIndexOf(Node* const subject_string, void StringIndexOf(Node* const subject_string,
Node* const subject_instance_type, Node* const subject_instance_type,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -895,6 +895,7 @@ static MachineRepresentation FilterRepresentation(MachineRepresentation rep) { ...@@ -895,6 +895,7 @@ static MachineRepresentation FilterRepresentation(MachineRepresentation rep) {
case MachineRepresentation::kNone: case MachineRepresentation::kNone:
break; break;
} }
UNREACHABLE(); UNREACHABLE();
} }
......
...@@ -253,6 +253,8 @@ void ExternalReferenceTable::AddReferences(Isolate* isolate) { ...@@ -253,6 +253,8 @@ void ExternalReferenceTable::AddReferences(Isolate* isolate) {
"libc_memset"); "libc_memset");
Add(ExternalReference::try_internalize_string_function(isolate).address(), Add(ExternalReference::try_internalize_string_function(isolate).address(),
"try_internalize_string_function"); "try_internalize_string_function");
Add(ExternalReference::check_object_type(isolate).address(),
"check_object_type");
#ifdef V8_INTL_SUPPORT #ifdef V8_INTL_SUPPORT
Add(ExternalReference::intl_convert_one_byte_to_lower(isolate).address(), Add(ExternalReference::intl_convert_one_byte_to_lower(isolate).address(),
"intl_convert_one_byte_to_lower"); "intl_convert_one_byte_to_lower");
......
...@@ -1167,7 +1167,7 @@ void AccessorAssembler::EmitFastElementsBoundsCheck(Node* object, ...@@ -1167,7 +1167,7 @@ void AccessorAssembler::EmitFastElementsBoundsCheck(Node* object,
} }
BIND(&if_array); BIND(&if_array);
{ {
var_length.Bind(SmiUntag(LoadJSArrayLength(object))); var_length.Bind(SmiUntag(LoadFastJSArrayLength(object)));
Goto(&length_loaded); Goto(&length_loaded);
} }
BIND(&length_loaded); BIND(&length_loaded);
...@@ -1281,7 +1281,7 @@ void AccessorAssembler::EmitElementLoad( ...@@ -1281,7 +1281,7 @@ void AccessorAssembler::EmitElementLoad(
// Bounds check. // Bounds check.
Node* length = Node* length =
SmiUntag(LoadObjectField(object, JSTypedArray::kLengthOffset)); SmiUntag(CAST(LoadObjectField(object, JSTypedArray::kLengthOffset)));
GotoIfNot(UintPtrLessThan(intptr_index, length), out_of_bounds); GotoIfNot(UintPtrLessThan(intptr_index, length), out_of_bounds);
// Backing store = external_pointer + base_pointer. // Backing store = external_pointer + base_pointer.
......
...@@ -225,7 +225,7 @@ void KeyedStoreGenericAssembler::TryChangeToHoleyMapMulti( ...@@ -225,7 +225,7 @@ void KeyedStoreGenericAssembler::TryChangeToHoleyMapMulti(
void KeyedStoreGenericAssembler::MaybeUpdateLengthAndReturn( void KeyedStoreGenericAssembler::MaybeUpdateLengthAndReturn(
Node* receiver, Node* index, Node* value, UpdateLength update_length) { Node* receiver, Node* index, Node* value, UpdateLength update_length) {
if (update_length != kDontChangeLength) { if (update_length != kDontChangeLength) {
Node* new_length = SmiTag(IntPtrAdd(index, IntPtrConstant(1))); Node* new_length = SmiTag(Signed(IntPtrAdd(index, IntPtrConstant(1))));
StoreObjectFieldNoWriteBarrier(receiver, JSArray::kLengthOffset, new_length, StoreObjectFieldNoWriteBarrier(receiver, JSArray::kLengthOffset, new_length,
MachineRepresentation::kTagged); MachineRepresentation::kTagged);
} }
...@@ -445,7 +445,7 @@ void KeyedStoreGenericAssembler::EmitGenericElementStore( ...@@ -445,7 +445,7 @@ void KeyedStoreGenericAssembler::EmitGenericElementStore(
} }
BIND(&if_array); BIND(&if_array);
{ {
Node* length = SmiUntag(LoadJSArrayLength(receiver)); Node* length = SmiUntag(LoadFastJSArrayLength(receiver));
GotoIf(UintPtrLessThan(intptr_index, length), &if_in_bounds); GotoIf(UintPtrLessThan(intptr_index, length), &if_in_bounds);
Node* capacity = SmiUntag(LoadFixedArrayBaseLength(elements)); Node* capacity = SmiUntag(LoadFixedArrayBaseLength(elements));
GotoIf(UintPtrGreaterThanOrEqual(intptr_index, capacity), &if_grow); GotoIf(UintPtrGreaterThanOrEqual(intptr_index, capacity), &if_grow);
......
...@@ -1377,7 +1377,7 @@ Node* InterpreterAssembler::LoadOSRNestingLevel() { ...@@ -1377,7 +1377,7 @@ Node* InterpreterAssembler::LoadOSRNestingLevel() {
void InterpreterAssembler::Abort(BailoutReason bailout_reason) { void InterpreterAssembler::Abort(BailoutReason bailout_reason) {
disable_stack_check_across_call_ = true; disable_stack_check_across_call_ = true;
Node* abort_id = SmiTag(Int32Constant(bailout_reason)); Node* abort_id = SmiConstant(bailout_reason);
CallRuntime(Runtime::kAbort, GetContext(), abort_id); CallRuntime(Runtime::kAbort, GetContext(), abort_id);
disable_stack_check_across_call_ = false; disable_stack_check_across_call_ = false;
} }
......
...@@ -8,6 +8,18 @@ ...@@ -8,6 +8,18 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2) {
if (rep1 == rep2) return true;
switch (rep1) {
case MachineRepresentation::kTaggedSigned:
return rep2 == MachineRepresentation::kTagged;
case MachineRepresentation ::kTaggedPointer:
return rep2 == MachineRepresentation ::kTagged;
default:
return false;
}
}
std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) { std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
return os << MachineReprToString(rep); return os << MachineReprToString(rep);
} }
......
...@@ -33,6 +33,8 @@ enum class MachineRepresentation { ...@@ -33,6 +33,8 @@ enum class MachineRepresentation {
kLastRepresentation = kSimd128 kLastRepresentation = kSimd128
}; };
bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2);
static_assert(static_cast<int>(MachineRepresentation::kLastRepresentation) < static_assert(static_cast<int>(MachineRepresentation::kLastRepresentation) <
kIntSize * kBitsPerByte, kIntSize * kBitsPerByte,
"Bit masks of MachineRepresentation should fit in an int"); "Bit masks of MachineRepresentation should fit in an int");
......
This diff is collapsed.
...@@ -410,12 +410,15 @@ TEST(TestOutOfScopeVariable) { ...@@ -410,12 +410,15 @@ TEST(TestOutOfScopeVariable) {
Label block2(&m); Label block2(&m);
Label block3(&m); Label block3(&m);
Label block4(&m); Label block4(&m);
m.Branch(m.WordEqual(m.Parameter(0), m.IntPtrConstant(0)), &block1, &block4); m.Branch(m.WordEqual(m.UncheckedCast<IntPtrT>(m.Parameter(0)),
m.IntPtrConstant(0)),
&block1, &block4);
m.Bind(&block4); m.Bind(&block4);
{ {
Variable var_object(&m, MachineRepresentation::kTagged); Variable var_object(&m, MachineRepresentation::kTagged);
m.Branch(m.WordEqual(m.Parameter(0), m.IntPtrConstant(0)), &block2, m.Branch(m.WordEqual(m.UncheckedCast<IntPtrT>(m.Parameter(0)),
&block3); m.IntPtrConstant(0)),
&block2, &block3);
m.Bind(&block2); m.Bind(&block2);
var_object.Bind(m.IntPtrConstant(55)); var_object.Bind(m.IntPtrConstant(55));
......
...@@ -170,7 +170,7 @@ TEST(FixedArrayAccessSmiIndex) { ...@@ -170,7 +170,7 @@ TEST(FixedArrayAccessSmiIndex) {
Handle<FixedArray> array = isolate->factory()->NewFixedArray(5); Handle<FixedArray> array = isolate->factory()->NewFixedArray(5);
array->set(4, Smi::FromInt(733)); array->set(4, Smi::FromInt(733));
m.Return(m.LoadFixedArrayElement(m.HeapConstant(array), m.Return(m.LoadFixedArrayElement(m.HeapConstant(array),
m.SmiTag(m.Int32Constant(4)), 0, m.SmiTag(m.IntPtrConstant(4)), 0,
CodeStubAssembler::SMI_PARAMETERS)); CodeStubAssembler::SMI_PARAMETERS));
FunctionTester ft(asm_tester.GenerateCode()); FunctionTester ft(asm_tester.GenerateCode());
MaybeHandle<Object> result = ft.Call(); MaybeHandle<Object> result = ft.Call();
...@@ -1775,15 +1775,15 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler { ...@@ -1775,15 +1775,15 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler {
Handle<Smi>(Smi::FromInt(2), isolate), SLOPPY) Handle<Smi>(Smi::FromInt(2), isolate), SLOPPY)
.Check(); .Check();
CodeStubArguments args(this, IntPtrConstant(kNumParams)); CodeStubArguments args(this, IntPtrConstant(kNumParams));
Variable arg_index(this, MachineType::PointerRepresentation()); TVariable<IntPtrT> arg_index(this);
Label bailout(this); Label bailout(this);
arg_index.Bind(IntPtrConstant(0)); arg_index = IntPtrConstant(0);
Node* length = BuildAppendJSArray(kind_, HeapConstant(array), args, Node* length = BuildAppendJSArray(kind_, HeapConstant(array), &args,
arg_index, &bailout); &arg_index, &bailout);
Return(length); Return(length);
BIND(&bailout); BIND(&bailout);
Return(SmiTag(IntPtrAdd(arg_index.value(), IntPtrConstant(2)))); Return(SmiTag(IntPtrAdd(arg_index, IntPtrConstant(2))));
FunctionTester ft(csa_tester->GenerateCode(), kNumParams); FunctionTester ft(csa_tester->GenerateCode(), kNumParams);
......
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