[cleanup] Limit Token usage to Parser, AST, BytecodeGenerator
and use a newly-introduced "enum class Operation" in all other places that so far passed Token::Values around. Also delete some related dead code along the way. Bug: v8:6921 Change-Id: I062f396d304aa62298cfeff202e3132a4a5597c1 Reviewed-on: https://chromium-review.googlesource.com/736851 Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#48944}
This commit is contained in:
parent
56c0acfb11
commit
9daf3e2039
@ -58,9 +58,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return r4; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return r3; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return r5; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return r1; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return r0; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return r0; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return r3; }
|
||||
|
||||
|
@ -58,9 +58,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return x4; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return x3; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return x5; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return x1; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return x0; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return x0; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return x3; }
|
||||
|
||||
|
@ -306,7 +306,7 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
|
||||
|
||||
BIND(&slow);
|
||||
CallRuntime(Runtime::kSetProperty, context(), a(), k, mapped_value,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
Goto(&done);
|
||||
|
||||
BIND(&detached);
|
||||
@ -998,7 +998,7 @@ TF_BUILTIN(FastArrayPush, CodeStubAssembler) {
|
||||
// TODO(danno): Use the KeyedStoreGeneric stub here when possible,
|
||||
// calling into the runtime to do the elements transition is overkill.
|
||||
CallRuntime(Runtime::kSetProperty, context, receiver, length, arg,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
Increment(&arg_index);
|
||||
// The runtime SetProperty call could have converted the array to dictionary
|
||||
// mode, which must be detected to abort the fast-path.
|
||||
@ -1045,7 +1045,7 @@ TF_BUILTIN(FastArrayPush, CodeStubAssembler) {
|
||||
// TODO(danno): Use the KeyedStoreGeneric stub here when possible,
|
||||
// calling into the runtime to do the elements transition is overkill.
|
||||
CallRuntime(Runtime::kSetProperty, context, receiver, length, arg,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
Increment(&arg_index);
|
||||
// The runtime SetProperty call could have converted the array to dictionary
|
||||
// mode, which must be detected to abort the fast-path.
|
||||
@ -1065,7 +1065,7 @@ TF_BUILTIN(FastArrayPush, CodeStubAssembler) {
|
||||
[this, receiver, context](Node* arg) {
|
||||
Node* length = LoadJSArrayLength(receiver);
|
||||
CallRuntime(Runtime::kSetProperty, context, receiver, length, arg,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
},
|
||||
arg_index);
|
||||
args.PopAndReturn(LoadJSArrayLength(receiver));
|
||||
|
@ -126,8 +126,7 @@ Node* AsyncBuiltinsAssembler::Await(
|
||||
Node* const key =
|
||||
HeapConstant(factory()->promise_forwarding_handler_symbol());
|
||||
CallRuntime(Runtime::kSetProperty, context, on_reject, key,
|
||||
TrueConstant(),
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
TrueConstant(), SmiConstant(LanguageMode::kStrict));
|
||||
|
||||
GotoIf(IsFalse(is_predicted_as_caught), &common);
|
||||
PromiseSetHandledHint(value);
|
||||
@ -141,7 +140,7 @@ Node* AsyncBuiltinsAssembler::Await(
|
||||
|
||||
Node* const key = HeapConstant(factory()->promise_handled_by_symbol());
|
||||
CallRuntime(Runtime::kSetProperty, context, throwaway, key, outer_promise,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
}
|
||||
|
||||
Goto(&do_perform_promise_then);
|
||||
|
@ -536,8 +536,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
|
||||
BIND(&dont_delete);
|
||||
{
|
||||
STATIC_ASSERT(LanguageModeSize == 2);
|
||||
GotoIf(SmiNotEqual(language_mode,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kSloppy))),
|
||||
GotoIf(SmiNotEqual(language_mode, SmiConstant(LanguageMode::kSloppy)),
|
||||
&slow);
|
||||
Return(FalseConstant());
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/code-stub-assembler.h"
|
||||
#include "src/ic/binary-op-assembler.h"
|
||||
#include "src/parsing/token.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -21,7 +20,7 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
|
||||
|
||||
protected:
|
||||
template <typename Descriptor>
|
||||
void EmitBitwiseOp(Token::Value op) {
|
||||
void EmitBitwiseOp(Operation op) {
|
||||
Node* left = Parameter(Descriptor::kLeft);
|
||||
Node* right = Parameter(Descriptor::kRight);
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
@ -52,12 +51,12 @@ class NumberBuiltinsAssembler : public CodeStubAssembler {
|
||||
}
|
||||
|
||||
template <typename Descriptor>
|
||||
void RelationalComparisonBuiltin(RelationalComparisonMode mode) {
|
||||
void RelationalComparisonBuiltin(Operation op) {
|
||||
Node* lhs = Parameter(Descriptor::kLeft);
|
||||
Node* rhs = Parameter(Descriptor::kRight);
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
|
||||
Return(RelationalComparison(mode, lhs, rhs, context));
|
||||
Return(RelationalComparison(op, lhs, rhs, context));
|
||||
}
|
||||
|
||||
template <typename Descriptor>
|
||||
@ -583,7 +582,7 @@ TF_BUILTIN(Add, AddStubAssembler) {
|
||||
BIND(&do_bigint_add);
|
||||
{
|
||||
Return(CallRuntime(Runtime::kBigIntBinaryOp, context, var_left.value(),
|
||||
var_right.value(), SmiConstant(Token::ADD)));
|
||||
var_right.value(), SmiConstant(Operation::kAdd)));
|
||||
}
|
||||
|
||||
BIND(&do_double_add);
|
||||
@ -710,7 +709,7 @@ TF_BUILTIN(Subtract, NumberBuiltinsAssembler) {
|
||||
{
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Return(CallRuntime(Runtime::kBigIntBinaryOp, context, var_left.value(),
|
||||
var_right.value(), SmiConstant(Token::SUB)));
|
||||
var_right.value(), SmiConstant(Operation::kSubtract)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -736,7 +735,7 @@ TF_BUILTIN(Multiply, NumberBuiltinsAssembler) {
|
||||
{
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Return(CallRuntime(Runtime::kBigIntBinaryOp, context, var_left.value(),
|
||||
var_right.value(), SmiConstant(Token::MUL)));
|
||||
var_right.value(), SmiConstant(Operation::kMultiply)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -820,7 +819,7 @@ TF_BUILTIN(Divide, NumberBuiltinsAssembler) {
|
||||
{
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Return(CallRuntime(Runtime::kBigIntBinaryOp, context, var_left.value(),
|
||||
var_right.value(), SmiConstant(Token::DIV)));
|
||||
var_right.value(), SmiConstant(Operation::kDivide)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -845,51 +844,48 @@ TF_BUILTIN(Modulus, NumberBuiltinsAssembler) {
|
||||
{
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Return(CallRuntime(Runtime::kBigIntBinaryOp, context, var_left.value(),
|
||||
var_right.value(), SmiConstant(Token::MOD)));
|
||||
var_right.value(), SmiConstant(Operation::kModulus)));
|
||||
}
|
||||
}
|
||||
|
||||
TF_BUILTIN(ShiftLeft, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::SHL);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kShiftLeft);
|
||||
}
|
||||
|
||||
TF_BUILTIN(ShiftRight, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::SAR);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kShiftRight);
|
||||
}
|
||||
|
||||
TF_BUILTIN(ShiftRightLogical, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::SHR);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kShiftRightLogical);
|
||||
}
|
||||
|
||||
TF_BUILTIN(BitwiseAnd, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::BIT_AND);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kBitwiseAnd);
|
||||
}
|
||||
|
||||
TF_BUILTIN(BitwiseOr, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::BIT_OR);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kBitwiseOr);
|
||||
}
|
||||
|
||||
TF_BUILTIN(BitwiseXor, NumberBuiltinsAssembler) {
|
||||
EmitBitwiseOp<Descriptor>(Token::BIT_XOR);
|
||||
EmitBitwiseOp<Descriptor>(Operation::kBitwiseXor);
|
||||
}
|
||||
|
||||
TF_BUILTIN(LessThan, NumberBuiltinsAssembler) {
|
||||
RelationalComparisonBuiltin<Descriptor>(RelationalComparisonMode::kLessThan);
|
||||
RelationalComparisonBuiltin<Descriptor>(Operation::kLessThan);
|
||||
}
|
||||
|
||||
TF_BUILTIN(LessThanOrEqual, NumberBuiltinsAssembler) {
|
||||
RelationalComparisonBuiltin<Descriptor>(
|
||||
RelationalComparisonMode::kLessThanOrEqual);
|
||||
RelationalComparisonBuiltin<Descriptor>(Operation::kLessThanOrEqual);
|
||||
}
|
||||
|
||||
TF_BUILTIN(GreaterThan, NumberBuiltinsAssembler) {
|
||||
RelationalComparisonBuiltin<Descriptor>(
|
||||
RelationalComparisonMode::kGreaterThan);
|
||||
RelationalComparisonBuiltin<Descriptor>(Operation::kGreaterThan);
|
||||
}
|
||||
|
||||
TF_BUILTIN(GreaterThanOrEqual, NumberBuiltinsAssembler) {
|
||||
RelationalComparisonBuiltin<Descriptor>(
|
||||
RelationalComparisonMode::kGreaterThanOrEqual);
|
||||
RelationalComparisonBuiltin<Descriptor>(Operation::kGreaterThanOrEqual);
|
||||
}
|
||||
|
||||
TF_BUILTIN(Equal, CodeStubAssembler) {
|
||||
|
@ -779,7 +779,7 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context,
|
||||
Node* const key =
|
||||
HeapConstant(isolate->factory()->promise_handled_by_symbol());
|
||||
CallRuntime(Runtime::kSetProperty, context, result, key, promise,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
Goto(&enqueue);
|
||||
|
||||
// 12. Perform EnqueueJob("PromiseJobs",
|
||||
@ -960,8 +960,7 @@ void PromiseBuiltinsAssembler::SetForwardingHandlerIfTrue(
|
||||
GotoIfNot(condition, &done);
|
||||
CallRuntime(Runtime::kSetProperty, context, object(),
|
||||
HeapConstant(factory()->promise_forwarding_handler_symbol()),
|
||||
TrueConstant(),
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
TrueConstant(), SmiConstant(LanguageMode::kStrict));
|
||||
Goto(&done);
|
||||
BIND(&done);
|
||||
}
|
||||
@ -975,7 +974,7 @@ void PromiseBuiltinsAssembler::SetPromiseHandledByIfTrue(
|
||||
GotoIfNot(HasInstanceType(promise, JS_PROMISE_TYPE), &done);
|
||||
CallRuntime(Runtime::kSetProperty, context, promise,
|
||||
HeapConstant(factory()->promise_handled_by_symbol()),
|
||||
handled_by(), SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
handled_by(), SmiConstant(LanguageMode::kStrict));
|
||||
Goto(&done);
|
||||
BIND(&done);
|
||||
}
|
||||
|
@ -439,8 +439,7 @@ TF_BUILTIN(ProxySetProperty, ProxiesCodeStubAssembler) {
|
||||
BIND(&failure);
|
||||
{
|
||||
Label if_throw(this, Label::kDeferred);
|
||||
Branch(SmiEqual(language_mode,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict))),
|
||||
Branch(SmiEqual(language_mode, SmiConstant(LanguageMode::kStrict)),
|
||||
&if_throw, &success);
|
||||
|
||||
BIND(&if_throw);
|
||||
@ -456,8 +455,7 @@ TF_BUILTIN(ProxySetProperty, ProxiesCodeStubAssembler) {
|
||||
{
|
||||
Label failure(this), throw_error(this, Label::kDeferred);
|
||||
|
||||
Branch(SmiEqual(language_mode,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict))),
|
||||
Branch(SmiEqual(language_mode, SmiConstant(LanguageMode::kStrict)),
|
||||
&throw_error, &failure);
|
||||
|
||||
BIND(&failure);
|
||||
|
@ -119,7 +119,7 @@ void RegExpBuiltinsAssembler::SlowStoreLastIndex(Node* context, Node* regexp,
|
||||
// Store through runtime.
|
||||
// TODO(ishell): Use SetPropertyStub here once available.
|
||||
Node* const name = HeapConstant(isolate()->factory()->lastIndex_string());
|
||||
Node* const language_mode = SmiConstant(Smi::FromEnum(LanguageMode::kStrict));
|
||||
Node* const language_mode = SmiConstant(LanguageMode::kStrict);
|
||||
CallRuntime(Runtime::kSetProperty, context, regexp, name, value,
|
||||
language_mode);
|
||||
}
|
||||
|
@ -296,8 +296,10 @@ void StringBuiltinsAssembler::StringEqual_Core(
|
||||
}
|
||||
}
|
||||
|
||||
void StringBuiltinsAssembler::GenerateStringRelationalComparison(
|
||||
Node* context, Node* left, Node* right, RelationalComparisonMode mode) {
|
||||
void StringBuiltinsAssembler::GenerateStringRelationalComparison(Node* context,
|
||||
Node* left,
|
||||
Node* right,
|
||||
Operation op) {
|
||||
VARIABLE(var_left, MachineRepresentation::kTagged, left);
|
||||
VARIABLE(var_right, MachineRepresentation::kTagged, right);
|
||||
|
||||
@ -400,59 +402,67 @@ void StringBuiltinsAssembler::GenerateStringRelationalComparison(
|
||||
MaybeDerefIndirectStrings(&var_left, lhs_instance_type, &var_right,
|
||||
rhs_instance_type, &restart);
|
||||
// TODO(bmeurer): Add support for two byte string relational comparisons.
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
TailCallRuntime(Runtime::kStringLessThan, context, lhs, rhs);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
TailCallRuntime(Runtime::kStringLessThanOrEqual, context, lhs, rhs);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
TailCallRuntime(Runtime::kStringGreaterThan, context, lhs, rhs);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
TailCallRuntime(Runtime::kStringGreaterThanOrEqual, context, lhs, rhs);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
BIND(&if_less);
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
case Operation::kLessThanOrEqual:
|
||||
Return(TrueConstant());
|
||||
break;
|
||||
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThan:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
Return(FalseConstant());
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
BIND(&if_equal);
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
case Operation::kGreaterThan:
|
||||
Return(FalseConstant());
|
||||
break;
|
||||
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
Return(TrueConstant());
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
BIND(&if_greater);
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
case Operation::kLessThanOrEqual:
|
||||
Return(FalseConstant());
|
||||
break;
|
||||
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThan:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
Return(TrueConstant());
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,15 +478,15 @@ TF_BUILTIN(StringLessThan, StringBuiltinsAssembler) {
|
||||
Node* left = Parameter(Descriptor::kLeft);
|
||||
Node* right = Parameter(Descriptor::kRight);
|
||||
GenerateStringRelationalComparison(context, left, right,
|
||||
RelationalComparisonMode::kLessThan);
|
||||
Operation::kLessThan);
|
||||
}
|
||||
|
||||
TF_BUILTIN(StringLessThanOrEqual, StringBuiltinsAssembler) {
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Node* left = Parameter(Descriptor::kLeft);
|
||||
Node* right = Parameter(Descriptor::kRight);
|
||||
GenerateStringRelationalComparison(
|
||||
context, left, right, RelationalComparisonMode::kLessThanOrEqual);
|
||||
GenerateStringRelationalComparison(context, left, right,
|
||||
Operation::kLessThanOrEqual);
|
||||
}
|
||||
|
||||
TF_BUILTIN(StringGreaterThan, StringBuiltinsAssembler) {
|
||||
@ -484,15 +494,15 @@ TF_BUILTIN(StringGreaterThan, StringBuiltinsAssembler) {
|
||||
Node* left = Parameter(Descriptor::kLeft);
|
||||
Node* right = Parameter(Descriptor::kRight);
|
||||
GenerateStringRelationalComparison(context, left, right,
|
||||
RelationalComparisonMode::kGreaterThan);
|
||||
Operation::kGreaterThan);
|
||||
}
|
||||
|
||||
TF_BUILTIN(StringGreaterThanOrEqual, StringBuiltinsAssembler) {
|
||||
Node* context = Parameter(Descriptor::kContext);
|
||||
Node* left = Parameter(Descriptor::kLeft);
|
||||
Node* right = Parameter(Descriptor::kRight);
|
||||
GenerateStringRelationalComparison(
|
||||
context, left, right, RelationalComparisonMode::kGreaterThanOrEqual);
|
||||
GenerateStringRelationalComparison(context, left, right,
|
||||
Operation::kGreaterThanOrEqual);
|
||||
}
|
||||
|
||||
TF_BUILTIN(StringCharAt, CodeStubAssembler) {
|
||||
@ -2113,8 +2123,8 @@ void StringTrimAssembler::Generate(String::TrimMode mode,
|
||||
SubStringFlags::FROM_TO_ARE_BOUNDED));
|
||||
|
||||
BIND(&if_runtime);
|
||||
arguments.PopAndReturn(CallRuntime(Runtime::kStringTrim, context, string,
|
||||
SmiConstant(Smi::FromEnum(mode))));
|
||||
arguments.PopAndReturn(
|
||||
CallRuntime(Runtime::kStringTrim, context, string, SmiConstant(mode)));
|
||||
|
||||
BIND(&return_emptystring);
|
||||
arguments.PopAndReturn(EmptyStringConstant());
|
||||
|
@ -46,8 +46,7 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
|
||||
|
||||
void GenerateStringEqual(Node* context, Node* left, Node* right);
|
||||
void GenerateStringRelationalComparison(Node* context, Node* left,
|
||||
Node* right,
|
||||
RelationalComparisonMode mode);
|
||||
Node* right, Operation op);
|
||||
|
||||
TNode<Smi> ToSmiBetweenZeroAnd(SloppyTNode<Context> context,
|
||||
SloppyTNode<Object> value,
|
||||
|
@ -94,29 +94,29 @@ Callable CodeFactory::StoreGlobalICInOptimizedCode(Isolate* isolate,
|
||||
}
|
||||
|
||||
// static
|
||||
Callable CodeFactory::BinaryOperation(Isolate* isolate, Token::Value op) {
|
||||
Callable CodeFactory::BinaryOperation(Isolate* isolate, Operation op) {
|
||||
switch (op) {
|
||||
case Token::SAR:
|
||||
case Operation::kShiftRight:
|
||||
return Builtins::CallableFor(isolate, Builtins::kShiftRight);
|
||||
case Token::SHL:
|
||||
case Operation::kShiftLeft:
|
||||
return Builtins::CallableFor(isolate, Builtins::kShiftLeft);
|
||||
case Token::SHR:
|
||||
case Operation::kShiftRightLogical:
|
||||
return Builtins::CallableFor(isolate, Builtins::kShiftRightLogical);
|
||||
case Token::ADD:
|
||||
case Operation::kAdd:
|
||||
return Builtins::CallableFor(isolate, Builtins::kAdd);
|
||||
case Token::SUB:
|
||||
case Operation::kSubtract:
|
||||
return Builtins::CallableFor(isolate, Builtins::kSubtract);
|
||||
case Token::MUL:
|
||||
case Operation::kMultiply:
|
||||
return Builtins::CallableFor(isolate, Builtins::kMultiply);
|
||||
case Token::DIV:
|
||||
case Operation::kDivide:
|
||||
return Builtins::CallableFor(isolate, Builtins::kDivide);
|
||||
case Token::MOD:
|
||||
case Operation::kModulus:
|
||||
return Builtins::CallableFor(isolate, Builtins::kModulus);
|
||||
case Token::BIT_OR:
|
||||
case Operation::kBitwiseOr:
|
||||
return Builtins::CallableFor(isolate, Builtins::kBitwiseOr);
|
||||
case Token::BIT_AND:
|
||||
case Operation::kBitwiseAnd:
|
||||
return Builtins::CallableFor(isolate, Builtins::kBitwiseAnd);
|
||||
case Token::BIT_XOR:
|
||||
case Operation::kBitwiseXor:
|
||||
return Builtins::CallableFor(isolate, Builtins::kBitwiseXor);
|
||||
default:
|
||||
break;
|
||||
@ -157,27 +157,6 @@ Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
|
||||
return make_callable(stub);
|
||||
}
|
||||
|
||||
// static
|
||||
Callable CodeFactory::StringCompare(Isolate* isolate, Token::Value token) {
|
||||
switch (token) {
|
||||
case Token::EQ:
|
||||
case Token::EQ_STRICT:
|
||||
return Builtins::CallableFor(isolate, Builtins::kStringEqual);
|
||||
case Token::LT:
|
||||
return Builtins::CallableFor(isolate, Builtins::kStringLessThan);
|
||||
case Token::GT:
|
||||
return Builtins::CallableFor(isolate, Builtins::kStringGreaterThan);
|
||||
case Token::LTE:
|
||||
return Builtins::CallableFor(isolate, Builtins::kStringLessThanOrEqual);
|
||||
case Token::GTE:
|
||||
return Builtins::CallableFor(isolate,
|
||||
Builtins::kStringGreaterThanOrEqual);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
// static
|
||||
Callable CodeFactory::ResumeGenerator(Isolate* isolate) {
|
||||
return Callable(BUILTIN_CODE(isolate, ResumeGeneratorTrampoline),
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/interface-descriptors.h"
|
||||
#include "src/parsing/token.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -40,7 +39,7 @@ class V8_EXPORT_PRIVATE CodeFactory final {
|
||||
static Callable FrameDropperTrampoline(Isolate* isolate);
|
||||
static Callable HandleDebuggerStatement(Isolate* isolate);
|
||||
|
||||
static Callable BinaryOperation(Isolate* isolate, Token::Value op);
|
||||
static Callable BinaryOperation(Isolate* isolate, Operation op);
|
||||
|
||||
static Callable ApiGetter(Isolate* isolate);
|
||||
|
||||
@ -57,7 +56,6 @@ class V8_EXPORT_PRIVATE CodeFactory final {
|
||||
static Callable StringAdd(Isolate* isolate,
|
||||
StringAddFlags flags = STRING_ADD_CHECK_NONE,
|
||||
PretenureFlag pretenure_flag = NOT_TENURED);
|
||||
static Callable StringCompare(Isolate* isolate, Token::Value token);
|
||||
|
||||
static Callable FastNewFunctionContext(Isolate* isolate,
|
||||
ScopeType scope_type);
|
||||
|
@ -8036,8 +8036,7 @@ void CodeStubAssembler::InitializeFieldsWithRoot(
|
||||
}
|
||||
|
||||
void CodeStubAssembler::BranchIfNumericRelationalComparison(
|
||||
RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true,
|
||||
Label* if_false) {
|
||||
Operation op, Node* lhs, Node* rhs, Label* if_true, Label* if_false) {
|
||||
CSA_SLOW_ASSERT(this, IsNumber(lhs));
|
||||
CSA_SLOW_ASSERT(this, IsNumber(rhs));
|
||||
|
||||
@ -8062,19 +8061,21 @@ void CodeStubAssembler::BranchIfNumericRelationalComparison(
|
||||
BIND(&if_rhsissmi);
|
||||
{
|
||||
// Both {lhs} and {rhs} are Smi, so just perform a fast Smi comparison.
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
BranchIfSmiLessThan(lhs, rhs, if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
BranchIfSmiLessThanOrEqual(lhs, rhs, if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
BranchIfSmiLessThan(rhs, lhs, if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
BranchIfSmiLessThanOrEqual(rhs, lhs, if_true, if_false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8125,19 +8126,21 @@ void CodeStubAssembler::BranchIfNumericRelationalComparison(
|
||||
Node* rhs = var_fcmp_rhs.value();
|
||||
|
||||
// Perform a fast floating point comparison.
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
Branch(Float64LessThan(lhs, rhs), if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
Branch(Float64LessThanOrEqual(lhs, rhs), if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
Branch(Float64GreaterThan(lhs, rhs), if_true, if_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
Branch(Float64GreaterThanOrEqual(lhs, rhs), if_true, if_false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8145,31 +8148,31 @@ void CodeStubAssembler::BranchIfNumericRelationalComparison(
|
||||
void CodeStubAssembler::GotoIfNumericGreaterThanOrEqual(Node* lhs, Node* rhs,
|
||||
Label* if_true) {
|
||||
Label if_false(this);
|
||||
BranchIfNumericRelationalComparison(
|
||||
RelationalComparisonMode::kGreaterThanOrEqual, lhs, rhs, if_true,
|
||||
&if_false);
|
||||
BranchIfNumericRelationalComparison(Operation::kGreaterThanOrEqual, lhs, rhs,
|
||||
if_true, &if_false);
|
||||
BIND(&if_false);
|
||||
}
|
||||
|
||||
namespace {
|
||||
RelationalComparisonMode Invert(RelationalComparisonMode mode) {
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
return RelationalComparisonMode::kGreaterThan;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
return RelationalComparisonMode::kGreaterThanOrEqual;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
return RelationalComparisonMode::kLessThan;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
return RelationalComparisonMode::kLessThanOrEqual;
|
||||
Operation Reverse(Operation op) {
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
return Operation::kGreaterThan;
|
||||
case Operation::kLessThanOrEqual:
|
||||
return Operation::kGreaterThanOrEqual;
|
||||
case Operation::kGreaterThan:
|
||||
return Operation::kLessThan;
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
return Operation::kLessThanOrEqual;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
Node* lhs, Node* rhs,
|
||||
Node* context,
|
||||
Node* CodeStubAssembler::RelationalComparison(Operation op, Node* lhs,
|
||||
Node* rhs, Node* context,
|
||||
Variable* var_type_feedback) {
|
||||
Label return_true(this), return_false(this), end(this);
|
||||
VARIABLE(result, MachineRepresentation::kTagged);
|
||||
@ -8221,19 +8224,21 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
CombineFeedback(var_type_feedback,
|
||||
SmiConstant(CompareOperationFeedback::kSignedSmall));
|
||||
}
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
BranchIfSmiLessThan(lhs, rhs, &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
BranchIfSmiLessThanOrEqual(lhs, rhs, &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
BranchIfSmiLessThan(rhs, lhs, &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
BranchIfSmiLessThanOrEqual(rhs, lhs, &return_true, &return_false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8256,9 +8261,9 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
if (var_type_feedback != nullptr) {
|
||||
var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kAny));
|
||||
}
|
||||
result.Bind(
|
||||
CallRuntime(Runtime::kBigIntCompareToNumber, NoContextConstant(),
|
||||
SmiConstant(static_cast<int>(Invert(mode))), rhs, lhs));
|
||||
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
|
||||
NoContextConstant(), SmiConstant(Reverse(op)),
|
||||
rhs, lhs));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -8313,9 +8318,9 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
var_type_feedback->Bind(
|
||||
SmiConstant(CompareOperationFeedback::kAny));
|
||||
}
|
||||
result.Bind(
|
||||
CallRuntime(Runtime::kBigIntCompareToNumber, NoContextConstant(),
|
||||
SmiConstant(static_cast<int>(mode)), lhs, rhs));
|
||||
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
|
||||
NoContextConstant(), SmiConstant(op), lhs,
|
||||
rhs));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -8380,9 +8385,9 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
var_type_feedback->Bind(
|
||||
SmiConstant(CompareOperationFeedback::kAny));
|
||||
}
|
||||
result.Bind(CallRuntime(
|
||||
Runtime::kBigIntCompareToNumber, NoContextConstant(),
|
||||
SmiConstant(static_cast<int>(Invert(mode))), rhs, lhs));
|
||||
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
|
||||
NoContextConstant(),
|
||||
SmiConstant(Reverse(op)), rhs, lhs));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -8419,17 +8424,17 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
|
||||
BIND(&if_rhsisheapnumber);
|
||||
{
|
||||
result.Bind(CallRuntime(
|
||||
Runtime::kBigIntCompareToNumber, NoContextConstant(),
|
||||
SmiConstant(static_cast<int>(mode)), lhs, rhs));
|
||||
result.Bind(CallRuntime(Runtime::kBigIntCompareToNumber,
|
||||
NoContextConstant(), SmiConstant(op), lhs,
|
||||
rhs));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
BIND(&if_rhsisbigint);
|
||||
{
|
||||
result.Bind(CallRuntime(
|
||||
Runtime::kBigIntCompareToBigInt, NoContextConstant(),
|
||||
SmiConstant(static_cast<int>(mode)), lhs, rhs));
|
||||
result.Bind(CallRuntime(Runtime::kBigIntCompareToBigInt,
|
||||
NoContextConstant(), SmiConstant(op), lhs,
|
||||
rhs));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -8463,27 +8468,29 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
CombineFeedback(var_type_feedback,
|
||||
SmiConstant(CompareOperationFeedback::kString));
|
||||
}
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
result.Bind(
|
||||
CallBuiltin(Builtins::kStringLessThan, context, lhs, rhs));
|
||||
Goto(&end);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
result.Bind(CallBuiltin(Builtins::kStringLessThanOrEqual,
|
||||
context, lhs, rhs));
|
||||
Goto(&end);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
result.Bind(CallBuiltin(Builtins::kStringGreaterThan, context,
|
||||
lhs, rhs));
|
||||
Goto(&end);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
result.Bind(CallBuiltin(Builtins::kStringGreaterThanOrEqual,
|
||||
context, lhs, rhs));
|
||||
Goto(&end);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8595,20 +8602,22 @@ Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
|
||||
Node* rhs = var_fcmp_rhs.value();
|
||||
|
||||
// Perform a fast floating point comparison.
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
Branch(Float64LessThan(lhs, rhs), &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
case Operation::kLessThanOrEqual:
|
||||
Branch(Float64LessThanOrEqual(lhs, rhs), &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
case Operation::kGreaterThan:
|
||||
Branch(Float64GreaterThan(lhs, rhs), &return_true, &return_false);
|
||||
break;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
Branch(Float64GreaterThanOrEqual(lhs, rhs), &return_true,
|
||||
&return_false);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10020,21 +10029,21 @@ void CodeStubAssembler::GotoIfNumber(Node* input, Label* is_number) {
|
||||
}
|
||||
|
||||
Node* CodeStubAssembler::BitwiseOp(Node* left32, Node* right32,
|
||||
Token::Value bitwise_op) {
|
||||
Operation bitwise_op) {
|
||||
switch (bitwise_op) {
|
||||
case Token::BIT_AND:
|
||||
case Operation::kBitwiseAnd:
|
||||
return ChangeInt32ToTagged(Signed(Word32And(left32, right32)));
|
||||
case Token::BIT_OR:
|
||||
case Operation::kBitwiseOr:
|
||||
return ChangeInt32ToTagged(Signed(Word32Or(left32, right32)));
|
||||
case Token::BIT_XOR:
|
||||
case Operation::kBitwiseXor:
|
||||
return ChangeInt32ToTagged(Signed(Word32Xor(left32, right32)));
|
||||
case Token::SHL:
|
||||
case Operation::kShiftLeft:
|
||||
return ChangeInt32ToTagged(
|
||||
Signed(Word32Shl(left32, Word32And(right32, Int32Constant(0x1f)))));
|
||||
case Token::SAR:
|
||||
case Operation::kShiftRight:
|
||||
return ChangeInt32ToTagged(
|
||||
Signed(Word32Sar(left32, Word32And(right32, Int32Constant(0x1f)))));
|
||||
case Token::SHR:
|
||||
case Operation::kShiftRightLogical:
|
||||
return ChangeUint32ToTagged(
|
||||
Unsigned(Word32Shr(left32, Word32And(right32, Int32Constant(0x1f)))));
|
||||
default:
|
||||
|
@ -285,7 +285,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
|
||||
void GotoIfNotNumber(Node* value, Label* is_not_number);
|
||||
void GotoIfNumber(Node* value, Label* is_number);
|
||||
|
||||
Node* BitwiseOp(Node* left32, Node* right32, Token::Value bitwise_op);
|
||||
Node* BitwiseOp(Node* left32, Node* right32, Operation bitwise_op);
|
||||
|
||||
// Allocate an object of the given size.
|
||||
Node* AllocateInNewSpace(Node* size, AllocationFlags flags = kNone);
|
||||
@ -1718,13 +1718,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
|
||||
void InitializeFieldsWithRoot(Node* object, Node* start_offset,
|
||||
Node* end_offset, Heap::RootListIndex root);
|
||||
|
||||
Node* RelationalComparison(RelationalComparisonMode mode, Node* lhs,
|
||||
Node* rhs, Node* context,
|
||||
Node* RelationalComparison(Operation op, Node* lhs, Node* rhs, Node* context,
|
||||
Variable* var_type_feedback = nullptr);
|
||||
|
||||
void BranchIfNumericRelationalComparison(RelationalComparisonMode mode,
|
||||
Node* lhs, Node* rhs, Label* if_true,
|
||||
Label* if_false);
|
||||
void BranchIfNumericRelationalComparison(Operation op, Node* lhs, Node* rhs,
|
||||
Label* if_true, Label* if_false);
|
||||
|
||||
void BranchIfAccessorPair(Node* value, Label* if_accessor_pair,
|
||||
Label* if_not_accessor_pair) {
|
||||
|
@ -629,6 +629,12 @@ class V8_EXPORT_PRIVATE CodeAssembler {
|
||||
TNode<Number> NumberConstant(double value);
|
||||
TNode<Smi> SmiConstant(Smi* value);
|
||||
TNode<Smi> SmiConstant(int value);
|
||||
template <typename E,
|
||||
typename = typename std::enable_if<std::is_enum<E>::value>::type>
|
||||
TNode<Smi> SmiConstant(E value) {
|
||||
STATIC_ASSERT(sizeof(E) <= sizeof(int));
|
||||
return SmiConstant(static_cast<int>(value));
|
||||
}
|
||||
TNode<HeapObject> UntypedHeapConstant(Handle<HeapObject> object);
|
||||
template <class Type>
|
||||
TNode<Type> HeapConstant(Handle<Type> object) {
|
||||
|
@ -155,7 +155,6 @@ bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) {
|
||||
case Runtime::kPushBlockContext:
|
||||
case Runtime::kPushCatchContext:
|
||||
case Runtime::kReThrow:
|
||||
case Runtime::kStringCompare:
|
||||
case Runtime::kStringEqual:
|
||||
case Runtime::kStringNotEqual:
|
||||
case Runtime::kStringLessThan:
|
||||
|
@ -1204,8 +1204,6 @@ class RuntimeCallTimerScope {
|
||||
SC(string_add_runtime_ext_to_one_byte, V8.StringAddRuntimeExtToOneByte) \
|
||||
SC(sub_string_runtime, V8.SubStringRuntime) \
|
||||
SC(sub_string_native, V8.SubStringNative) \
|
||||
SC(string_compare_native, V8.StringCompareNative) \
|
||||
SC(string_compare_runtime, V8.StringCompareRuntime) \
|
||||
SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
|
||||
SC(regexp_entry_native, V8.RegExpEntryNative) \
|
||||
SC(number_to_string_native, V8.NumberToStringNative) \
|
||||
|
@ -1301,6 +1301,33 @@ class CompareOperationFeedback {
|
||||
};
|
||||
};
|
||||
|
||||
enum class Operation {
|
||||
// Binary operations.
|
||||
kAdd,
|
||||
kSubtract,
|
||||
kMultiply,
|
||||
kDivide,
|
||||
kModulus,
|
||||
kBitwiseAnd,
|
||||
kBitwiseOr,
|
||||
kBitwiseXor,
|
||||
kShiftLeft,
|
||||
kShiftRight,
|
||||
kShiftRightLogical,
|
||||
// Unary operations.
|
||||
kBitwiseNot,
|
||||
kNegate,
|
||||
kIncrement,
|
||||
kDecrement,
|
||||
// Compare operations.
|
||||
kEqual,
|
||||
kStrictEqual,
|
||||
kLessThan,
|
||||
kLessThanOrEqual,
|
||||
kGreaterThan,
|
||||
kGreaterThanOrEqual,
|
||||
};
|
||||
|
||||
// Type feedback is encoded in such a way that, we can combine the feedback
|
||||
// at different points by performing an 'OR' operation. Type feedback moves
|
||||
// to a more generic type when we combine feedback.
|
||||
|
@ -57,9 +57,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return no_reg; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return ebx; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return edi; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return edx; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return eax; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return ecx; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return eax; }
|
||||
|
||||
|
@ -971,12 +971,12 @@ void AccessorAssembler::HandleStoreToProxy(const StoreICParameters* p,
|
||||
VARIABLE(var_index, MachineType::PointerRepresentation());
|
||||
VARIABLE(var_unique, MachineRepresentation::kTagged);
|
||||
VARIABLE(var_language_mode, MachineRepresentation::kTaggedSigned,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
|
||||
Label if_index(this), if_unique_name(this), language_mode_determined(this),
|
||||
to_name_failed(this, Label::kDeferred);
|
||||
BranchIfStrictMode(p->vector, p->slot, &language_mode_determined);
|
||||
var_language_mode.Bind(SmiConstant(Smi::FromEnum(LanguageMode::kSloppy)));
|
||||
var_language_mode.Bind(SmiConstant(LanguageMode::kSloppy));
|
||||
Goto(&language_mode_determined);
|
||||
BIND(&language_mode_determined);
|
||||
|
||||
|
@ -193,7 +193,7 @@ Node* BinaryOpAssembler::Generate_AddWithFeedback(Node* context, Node* lhs,
|
||||
{
|
||||
var_type_feedback.Bind(SmiConstant(BinaryOperationFeedback::kBigInt));
|
||||
var_result.Bind(CallRuntime(Runtime::kBigIntBinaryOp, context, lhs, rhs,
|
||||
SmiConstant(Token::ADD)));
|
||||
SmiConstant(Operation::kAdd)));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ Node* BinaryOpAssembler::Generate_AddWithFeedback(Node* context, Node* lhs,
|
||||
Node* BinaryOpAssembler::Generate_BinaryOperationWithFeedback(
|
||||
Node* context, Node* lhs, Node* rhs, Node* slot_id, Node* feedback_vector,
|
||||
const SmiOperation& smiOperation, const FloatOperation& floatOperation,
|
||||
Token::Value opcode, bool rhs_is_smi) {
|
||||
Operation op, bool rhs_is_smi) {
|
||||
Label do_float_operation(this), end(this), call_stub(this),
|
||||
check_rhsisoddball(this, Label::kDeferred), call_with_any_feedback(this),
|
||||
if_lhsisnotnumber(this, Label::kDeferred),
|
||||
@ -373,7 +373,7 @@ Node* BinaryOpAssembler::Generate_BinaryOperationWithFeedback(
|
||||
{
|
||||
var_type_feedback.Bind(SmiConstant(BinaryOperationFeedback::kBigInt));
|
||||
var_result.Bind(CallRuntime(Runtime::kBigIntBinaryOp, context, lhs, rhs,
|
||||
SmiConstant(opcode)));
|
||||
SmiConstant(op)));
|
||||
Goto(&end);
|
||||
}
|
||||
|
||||
@ -386,17 +386,17 @@ Node* BinaryOpAssembler::Generate_BinaryOperationWithFeedback(
|
||||
BIND(&call_stub);
|
||||
{
|
||||
Node* result;
|
||||
switch (opcode) {
|
||||
case Token::SUB:
|
||||
switch (op) {
|
||||
case Operation::kSubtract:
|
||||
result = CallBuiltin(Builtins::kSubtract, context, lhs, rhs);
|
||||
break;
|
||||
case Token::MUL:
|
||||
case Operation::kMultiply:
|
||||
result = CallBuiltin(Builtins::kMultiply, context, lhs, rhs);
|
||||
break;
|
||||
case Token::DIV:
|
||||
case Operation::kDivide:
|
||||
result = CallBuiltin(Builtins::kDivide, context, lhs, rhs);
|
||||
break;
|
||||
case Token::MOD:
|
||||
case Operation::kModulus:
|
||||
result = CallBuiltin(Builtins::kModulus, context, lhs, rhs);
|
||||
break;
|
||||
default:
|
||||
@ -455,7 +455,7 @@ Node* BinaryOpAssembler::Generate_SubtractWithFeedback(Node* context, Node* lhs,
|
||||
};
|
||||
return Generate_BinaryOperationWithFeedback(
|
||||
context, lhs, rhs, slot_id, feedback_vector, smiFunction, floatFunction,
|
||||
Token::SUB, rhs_is_smi);
|
||||
Operation::kSubtract, rhs_is_smi);
|
||||
}
|
||||
|
||||
Node* BinaryOpAssembler::Generate_MultiplyWithFeedback(Node* context, Node* lhs,
|
||||
@ -474,7 +474,7 @@ Node* BinaryOpAssembler::Generate_MultiplyWithFeedback(Node* context, Node* lhs,
|
||||
};
|
||||
return Generate_BinaryOperationWithFeedback(
|
||||
context, lhs, rhs, slot_id, feedback_vector, smiFunction, floatFunction,
|
||||
Token::MUL, rhs_is_smi);
|
||||
Operation::kMultiply, rhs_is_smi);
|
||||
}
|
||||
|
||||
Node* BinaryOpAssembler::Generate_DivideWithFeedback(
|
||||
@ -508,7 +508,7 @@ Node* BinaryOpAssembler::Generate_DivideWithFeedback(
|
||||
};
|
||||
return Generate_BinaryOperationWithFeedback(
|
||||
context, dividend, divisor, slot_id, feedback_vector, smiFunction,
|
||||
floatFunction, Token::DIV, rhs_is_smi);
|
||||
floatFunction, Operation::kDivide, rhs_is_smi);
|
||||
}
|
||||
|
||||
Node* BinaryOpAssembler::Generate_ModulusWithFeedback(
|
||||
@ -526,7 +526,7 @@ Node* BinaryOpAssembler::Generate_ModulusWithFeedback(
|
||||
};
|
||||
return Generate_BinaryOperationWithFeedback(
|
||||
context, dividend, divisor, slot_id, feedback_vector, smiFunction,
|
||||
floatFunction, Token::MOD, rhs_is_smi);
|
||||
floatFunction, Operation::kModulus, rhs_is_smi);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -49,7 +49,7 @@ class BinaryOpAssembler : public CodeStubAssembler {
|
||||
Node* Generate_BinaryOperationWithFeedback(
|
||||
Node* context, Node* lhs, Node* rhs, Node* slot_id, Node* feedback_vector,
|
||||
const SmiOperation& smiOperation, const FloatOperation& floatOperation,
|
||||
Token::Value opcode, bool rhs_is_smi);
|
||||
Operation op, bool rhs_is_smi);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -1014,10 +1014,10 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric() {
|
||||
{
|
||||
Comment("KeyedStoreGeneric_slow");
|
||||
VARIABLE(var_language_mode, MachineRepresentation::kTaggedSigned,
|
||||
SmiConstant(Smi::FromEnum(LanguageMode::kStrict)));
|
||||
SmiConstant(LanguageMode::kStrict));
|
||||
Label call_runtime(this);
|
||||
BranchIfStrictMode(vector, slot, &call_runtime);
|
||||
var_language_mode.Bind(SmiConstant(Smi::FromEnum(LanguageMode::kSloppy)));
|
||||
var_language_mode.Bind(SmiConstant(LanguageMode::kSloppy));
|
||||
Goto(&call_runtime);
|
||||
BIND(&call_runtime);
|
||||
TailCallRuntime(Runtime::kSetProperty, context, receiver, name, value,
|
||||
|
@ -262,12 +262,6 @@ void StringCharCodeAtDescriptor::InitializePlatformSpecific(
|
||||
DefaultInitializePlatformSpecific(data, kParameterCount);
|
||||
}
|
||||
|
||||
void StringCompareDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {LeftRegister(), RightRegister()};
|
||||
data->InitializePlatformSpecific(arraysize(registers), registers);
|
||||
}
|
||||
|
||||
void TypeConversionDescriptor::InitializePlatformSpecific(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {ArgumentRegister()};
|
||||
|
@ -62,7 +62,6 @@ class PlatformInterfaceDescriptor;
|
||||
V(StringAdd) \
|
||||
V(StringCharAt) \
|
||||
V(StringCharCodeAt) \
|
||||
V(StringCompare) \
|
||||
V(ForInPrepare) \
|
||||
V(GetProperty) \
|
||||
V(ArgumentAdaptor) \
|
||||
@ -740,15 +739,6 @@ class StringCharCodeAtDescriptor final : public CallInterfaceDescriptor {
|
||||
CallInterfaceDescriptor)
|
||||
};
|
||||
|
||||
class StringCompareDescriptor : public CallInterfaceDescriptor {
|
||||
public:
|
||||
DEFINE_PARAMETERS(kLeft, kRight)
|
||||
DECLARE_DESCRIPTOR(StringCompareDescriptor, CallInterfaceDescriptor)
|
||||
|
||||
static const Register LeftRegister();
|
||||
static const Register RightRegister();
|
||||
};
|
||||
|
||||
class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
|
||||
public:
|
||||
DEFINE_PARAMETERS(kFunction, kNewTarget, kActualArgumentsCount,
|
||||
|
@ -935,7 +935,7 @@ class InterpreterBitwiseBinaryOpAssembler : public InterpreterAssembler {
|
||||
OperandScale operand_scale)
|
||||
: InterpreterAssembler(state, bytecode, operand_scale) {}
|
||||
|
||||
void BitwiseBinaryOpWithFeedback(Token::Value bitwise_op) {
|
||||
void BitwiseBinaryOpWithFeedback(Operation bitwise_op) {
|
||||
Node* reg_index = BytecodeOperandReg(0);
|
||||
Node* left = LoadRegister(reg_index);
|
||||
Node* right = GetAccumulator();
|
||||
@ -986,7 +986,7 @@ class InterpreterBitwiseBinaryOpAssembler : public InterpreterAssembler {
|
||||
Dispatch();
|
||||
}
|
||||
|
||||
void BitwiseBinaryOpWithSmi(Token::Value bitwise_op) {
|
||||
void BitwiseBinaryOpWithSmi(Operation bitwise_op) {
|
||||
Node* left = GetAccumulator();
|
||||
Node* right = BytecodeOperandImmSmi(0);
|
||||
Node* slot_index = BytecodeOperandIdx(1);
|
||||
@ -1022,21 +1022,21 @@ class InterpreterBitwiseBinaryOpAssembler : public InterpreterAssembler {
|
||||
//
|
||||
// BitwiseOr register <src> to accumulator.
|
||||
IGNITION_HANDLER(BitwiseOr, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::BIT_OR);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kBitwiseOr);
|
||||
}
|
||||
|
||||
// BitwiseXor <src>
|
||||
//
|
||||
// BitwiseXor register <src> to accumulator.
|
||||
IGNITION_HANDLER(BitwiseXor, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::BIT_XOR);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kBitwiseXor);
|
||||
}
|
||||
|
||||
// BitwiseAnd <src>
|
||||
//
|
||||
// BitwiseAnd register <src> to accumulator.
|
||||
IGNITION_HANDLER(BitwiseAnd, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::BIT_AND);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kBitwiseAnd);
|
||||
}
|
||||
|
||||
// ShiftLeft <src>
|
||||
@ -1046,7 +1046,7 @@ IGNITION_HANDLER(BitwiseAnd, InterpreterBitwiseBinaryOpAssembler) {
|
||||
// before the operation. 5 lsb bits from the accumulator are used as count
|
||||
// i.e. <src> << (accumulator & 0x1F).
|
||||
IGNITION_HANDLER(ShiftLeft, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::SHL);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kShiftLeft);
|
||||
}
|
||||
|
||||
// ShiftRight <src>
|
||||
@ -1056,7 +1056,7 @@ IGNITION_HANDLER(ShiftLeft, InterpreterBitwiseBinaryOpAssembler) {
|
||||
// accumulator to uint32 before the operation. 5 lsb bits from the accumulator
|
||||
// are used as count i.e. <src> >> (accumulator & 0x1F).
|
||||
IGNITION_HANDLER(ShiftRight, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::SAR);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kShiftRight);
|
||||
}
|
||||
|
||||
// ShiftRightLogical <src>
|
||||
@ -1066,28 +1066,28 @@ IGNITION_HANDLER(ShiftRight, InterpreterBitwiseBinaryOpAssembler) {
|
||||
// uint32 before the operation 5 lsb bits from the accumulator are used as
|
||||
// count i.e. <src> << (accumulator & 0x1F).
|
||||
IGNITION_HANDLER(ShiftRightLogical, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithFeedback(Token::SHR);
|
||||
BitwiseBinaryOpWithFeedback(Operation::kShiftRightLogical);
|
||||
}
|
||||
|
||||
// BitwiseOrSmi <imm>
|
||||
//
|
||||
// BitwiseOrSmi accumulator with <imm>.
|
||||
IGNITION_HANDLER(BitwiseOrSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::BIT_OR);
|
||||
BitwiseBinaryOpWithSmi(Operation::kBitwiseOr);
|
||||
}
|
||||
|
||||
// BitwiseXorSmi <imm>
|
||||
//
|
||||
// BitwiseXorSmi accumulator with <imm>.
|
||||
IGNITION_HANDLER(BitwiseXorSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::BIT_XOR);
|
||||
BitwiseBinaryOpWithSmi(Operation::kBitwiseXor);
|
||||
}
|
||||
|
||||
// BitwiseAndSmi <imm>
|
||||
//
|
||||
// BitwiseAndSmi accumulator with <imm>.
|
||||
IGNITION_HANDLER(BitwiseAndSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::BIT_AND);
|
||||
BitwiseBinaryOpWithSmi(Operation::kBitwiseAnd);
|
||||
}
|
||||
|
||||
// BitwiseNot <feedback_slot>
|
||||
@ -1122,7 +1122,8 @@ IGNITION_HANDLER(BitwiseNot, InterpreterAssembler) {
|
||||
UpdateFeedback(SmiConstant(BinaryOperationFeedback::kBigInt), feedback_vector,
|
||||
slot_index);
|
||||
SetAccumulator(CallRuntime(Runtime::kBigIntUnaryOp, context,
|
||||
var_bigint.value(), SmiConstant(Token::BIT_NOT)));
|
||||
var_bigint.value(),
|
||||
SmiConstant(Operation::kBitwiseNot)));
|
||||
Dispatch();
|
||||
}
|
||||
|
||||
@ -1132,7 +1133,7 @@ IGNITION_HANDLER(BitwiseNot, InterpreterAssembler) {
|
||||
// The accumulator is converted to an int32 before the operation. The 5
|
||||
// lsb bits from <imm> are used as count i.e. <src> << (<imm> & 0x1F).
|
||||
IGNITION_HANDLER(ShiftLeftSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::SHL);
|
||||
BitwiseBinaryOpWithSmi(Operation::kShiftLeft);
|
||||
}
|
||||
|
||||
// ShiftRightSmi <imm>
|
||||
@ -1141,7 +1142,7 @@ IGNITION_HANDLER(ShiftLeftSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
// extended. The accumulator is converted to an int32 before the operation. The
|
||||
// 5 lsb bits from <imm> are used as count i.e. <src> >> (<imm> & 0x1F).
|
||||
IGNITION_HANDLER(ShiftRightSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::SAR);
|
||||
BitwiseBinaryOpWithSmi(Operation::kShiftRight);
|
||||
}
|
||||
|
||||
// ShiftRightLogicalSmi <imm>
|
||||
@ -1150,7 +1151,7 @@ IGNITION_HANDLER(ShiftRightSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
// extended. The accumulator is converted to an int32 before the operation. The
|
||||
// 5 lsb bits from <imm> are used as count i.e. <src> >>> (<imm> & 0x1F).
|
||||
IGNITION_HANDLER(ShiftRightLogicalSmi, InterpreterBitwiseBinaryOpAssembler) {
|
||||
BitwiseBinaryOpWithSmi(Token::SHR);
|
||||
BitwiseBinaryOpWithSmi(Operation::kShiftRightLogical);
|
||||
}
|
||||
|
||||
class UnaryNumericOpAssembler : public InterpreterAssembler {
|
||||
@ -1298,7 +1299,7 @@ class NegateAssemblerImpl : public UnaryNumericOpAssembler {
|
||||
|
||||
Node* BigIntOp(Node* bigint_value) override {
|
||||
return CallRuntime(Runtime::kBigIntUnaryOp, GetContext(), bigint_value,
|
||||
SmiConstant(Token::SUB));
|
||||
SmiConstant(Operation::kNegate));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1351,8 +1352,8 @@ class IncDecAssembler : public UnaryNumericOpAssembler {
|
||||
OperandScale operand_scale)
|
||||
: UnaryNumericOpAssembler(state, bytecode, operand_scale) {}
|
||||
|
||||
Token::Value op() {
|
||||
DCHECK(op_ == Token::INC || op_ == Token::DEC);
|
||||
Operation op() {
|
||||
DCHECK(op_ == Operation::kIncrement || op_ == Operation::kDecrement);
|
||||
return op_;
|
||||
}
|
||||
|
||||
@ -1361,8 +1362,9 @@ class IncDecAssembler : public UnaryNumericOpAssembler {
|
||||
// Try fast Smi operation first.
|
||||
Node* value = BitcastTaggedToWord(smi_value);
|
||||
Node* one = BitcastTaggedToWord(SmiConstant(1));
|
||||
Node* pair = op() == Token::INC ? IntPtrAddWithOverflow(value, one)
|
||||
: IntPtrSubWithOverflow(value, one);
|
||||
Node* pair = op() == Operation::kIncrement
|
||||
? IntPtrAddWithOverflow(value, one)
|
||||
: IntPtrSubWithOverflow(value, one);
|
||||
Node* overflow = Projection(1, pair);
|
||||
|
||||
// Check if the Smi operation overflowed.
|
||||
@ -1383,8 +1385,9 @@ class IncDecAssembler : public UnaryNumericOpAssembler {
|
||||
}
|
||||
|
||||
Node* FloatOp(Node* float_value) override {
|
||||
return op() == Token::INC ? Float64Add(float_value, Float64Constant(1.0))
|
||||
: Float64Sub(float_value, Float64Constant(1.0));
|
||||
return op() == Operation::kIncrement
|
||||
? Float64Add(float_value, Float64Constant(1.0))
|
||||
: Float64Sub(float_value, Float64Constant(1.0));
|
||||
}
|
||||
|
||||
Node* BigIntOp(Node* bigint_value) override {
|
||||
@ -1393,17 +1396,17 @@ class IncDecAssembler : public UnaryNumericOpAssembler {
|
||||
}
|
||||
|
||||
void IncWithFeedback() {
|
||||
op_ = Token::INC;
|
||||
op_ = Operation::kIncrement;
|
||||
UnaryOpWithFeedback();
|
||||
}
|
||||
|
||||
void DecWithFeedback() {
|
||||
op_ = Token::DEC;
|
||||
op_ = Operation::kDecrement;
|
||||
UnaryOpWithFeedback();
|
||||
}
|
||||
|
||||
private:
|
||||
Token::Value op_ = Token::ILLEGAL;
|
||||
Operation op_ = Operation::kEqual; // Dummy initialization.
|
||||
};
|
||||
|
||||
// Inc
|
||||
@ -1796,7 +1799,7 @@ class InterpreterCompareOpAssembler : public InterpreterAssembler {
|
||||
OperandScale operand_scale)
|
||||
: InterpreterAssembler(state, bytecode, operand_scale) {}
|
||||
|
||||
void CompareOpWithFeedback(Token::Value compare_op) {
|
||||
void CompareOpWithFeedback(Operation compare_op) {
|
||||
Node* reg_index = BytecodeOperandReg(0);
|
||||
Node* lhs = LoadRegister(reg_index);
|
||||
Node* rhs = GetAccumulator();
|
||||
@ -1805,29 +1808,18 @@ class InterpreterCompareOpAssembler : public InterpreterAssembler {
|
||||
Variable var_type_feedback(this, MachineRepresentation::kTagged);
|
||||
Node* result;
|
||||
switch (compare_op) {
|
||||
case Token::EQ:
|
||||
case Operation::kEqual:
|
||||
result = Equal(lhs, rhs, context, &var_type_feedback);
|
||||
break;
|
||||
case Token::EQ_STRICT:
|
||||
case Operation::kStrictEqual:
|
||||
result = StrictEqual(lhs, rhs, &var_type_feedback);
|
||||
break;
|
||||
case Token::LT:
|
||||
result = RelationalComparison(RelationalComparisonMode::kLessThan, lhs,
|
||||
rhs, context, &var_type_feedback);
|
||||
break;
|
||||
case Token::GT:
|
||||
result = RelationalComparison(RelationalComparisonMode::kGreaterThan,
|
||||
lhs, rhs, context, &var_type_feedback);
|
||||
break;
|
||||
case Token::LTE:
|
||||
result =
|
||||
RelationalComparison(RelationalComparisonMode::kLessThanOrEqual,
|
||||
lhs, rhs, context, &var_type_feedback);
|
||||
break;
|
||||
case Token::GTE:
|
||||
result =
|
||||
RelationalComparison(RelationalComparisonMode::kGreaterThanOrEqual,
|
||||
lhs, rhs, context, &var_type_feedback);
|
||||
case Operation::kLessThan:
|
||||
case Operation::kGreaterThan:
|
||||
case Operation::kLessThanOrEqual:
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
result = RelationalComparison(compare_op, lhs, rhs, context,
|
||||
&var_type_feedback);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -1845,28 +1837,28 @@ class InterpreterCompareOpAssembler : public InterpreterAssembler {
|
||||
//
|
||||
// Test if the value in the <src> register equals the accumulator.
|
||||
IGNITION_HANDLER(TestEqual, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::EQ);
|
||||
CompareOpWithFeedback(Operation::kEqual);
|
||||
}
|
||||
|
||||
// TestEqualStrict <src>
|
||||
//
|
||||
// Test if the value in the <src> register is strictly equal to the accumulator.
|
||||
IGNITION_HANDLER(TestEqualStrict, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::EQ_STRICT);
|
||||
CompareOpWithFeedback(Operation::kStrictEqual);
|
||||
}
|
||||
|
||||
// TestLessThan <src>
|
||||
//
|
||||
// Test if the value in the <src> register is less than the accumulator.
|
||||
IGNITION_HANDLER(TestLessThan, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::LT);
|
||||
CompareOpWithFeedback(Operation::kLessThan);
|
||||
}
|
||||
|
||||
// TestGreaterThan <src>
|
||||
//
|
||||
// Test if the value in the <src> register is greater than the accumulator.
|
||||
IGNITION_HANDLER(TestGreaterThan, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::GT);
|
||||
CompareOpWithFeedback(Operation::kGreaterThan);
|
||||
}
|
||||
|
||||
// TestLessThanOrEqual <src>
|
||||
@ -1874,7 +1866,7 @@ IGNITION_HANDLER(TestGreaterThan, InterpreterCompareOpAssembler) {
|
||||
// Test if the value in the <src> register is less than or equal to the
|
||||
// accumulator.
|
||||
IGNITION_HANDLER(TestLessThanOrEqual, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::LTE);
|
||||
CompareOpWithFeedback(Operation::kLessThanOrEqual);
|
||||
}
|
||||
|
||||
// TestGreaterThanOrEqual <src>
|
||||
@ -1882,7 +1874,7 @@ IGNITION_HANDLER(TestLessThanOrEqual, InterpreterCompareOpAssembler) {
|
||||
// Test if the value in the <src> register is greater than or equal to the
|
||||
// accumulator.
|
||||
IGNITION_HANDLER(TestGreaterThanOrEqual, InterpreterCompareOpAssembler) {
|
||||
CompareOpWithFeedback(Token::Value::GTE);
|
||||
CompareOpWithFeedback(Operation::kGreaterThanOrEqual);
|
||||
}
|
||||
|
||||
// TestEqualStrictNoFeedback <src>
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "src/base/macros.h"
|
||||
#include "src/builtins/builtins.h"
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
#include "src/parsing/token.h"
|
||||
#include "src/runtime/runtime.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "src/field-type.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/parsing/token.h"
|
||||
#include "src/property-descriptor.h"
|
||||
#include "src/string-hasher.h"
|
||||
#include "src/transitions.h"
|
||||
|
@ -56,9 +56,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return t0; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return a3; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return t1; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return a1; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return a0; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return a0; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return a3; }
|
||||
|
||||
|
@ -56,9 +56,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return a4; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return a3; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return a5; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return a1; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return a0; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return a0; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return a3; }
|
||||
|
||||
|
@ -84,6 +84,24 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
bool ComparisonResultToBool(Operation op, ComparisonResult result) {
|
||||
switch (op) {
|
||||
case Operation::kLessThan:
|
||||
return result == ComparisonResult::kLessThan;
|
||||
case Operation::kLessThanOrEqual:
|
||||
return result == ComparisonResult::kLessThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
case Operation::kGreaterThan:
|
||||
return result == ComparisonResult::kGreaterThan;
|
||||
case Operation::kGreaterThanOrEqual:
|
||||
return result == ComparisonResult::kGreaterThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, InstanceType instance_type) {
|
||||
switch (instance_type) {
|
||||
#define WRITE_TYPE(TYPE) \
|
||||
@ -506,7 +524,7 @@ bool NumberEquals(Handle<Object> x, Handle<Object> y) {
|
||||
return NumberEquals(*x, *y);
|
||||
}
|
||||
|
||||
ComparisonResult Invert(ComparisonResult result) {
|
||||
ComparisonResult Reverse(ComparisonResult result) {
|
||||
if (result == ComparisonResult::kLessThan) {
|
||||
return ComparisonResult::kGreaterThan;
|
||||
}
|
||||
@ -544,7 +562,7 @@ Maybe<ComparisonResult> Object::Compare(Handle<Object> x, Handle<Object> y) {
|
||||
return Just(BigInt::CompareToBigInt(Handle<BigInt>::cast(x),
|
||||
Handle<BigInt>::cast(y)));
|
||||
} else if (x_is_number) {
|
||||
return Just(Invert(BigInt::CompareToNumber(Handle<BigInt>::cast(y), x)));
|
||||
return Just(Reverse(BigInt::CompareToNumber(Handle<BigInt>::cast(y), x)));
|
||||
} else {
|
||||
return Just(BigInt::CompareToNumber(Handle<BigInt>::cast(x), y));
|
||||
}
|
||||
|
@ -893,22 +893,6 @@ enum FixedArraySubInstanceType {
|
||||
LAST_FIXED_ARRAY_SUB_TYPE = WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE
|
||||
};
|
||||
|
||||
enum class RelationalComparisonMode {
|
||||
kLessThan,
|
||||
kLessThanOrEqual,
|
||||
kGreaterThan,
|
||||
kGreaterThanOrEqual
|
||||
};
|
||||
|
||||
// TODO(bmeurer): Remove this in favor of the ComparisonResult below.
|
||||
enum CompareResult {
|
||||
LESS = -1,
|
||||
EQUAL = 0,
|
||||
GREATER = 1,
|
||||
|
||||
NOT_EQUAL = GREATER
|
||||
};
|
||||
|
||||
// Result of an abstract relational comparison of x and y, implemented according
|
||||
// to ES6 section 7.2.11 Abstract Relational Comparison.
|
||||
enum class ComparisonResult {
|
||||
@ -919,22 +903,7 @@ enum class ComparisonResult {
|
||||
};
|
||||
|
||||
// (Returns false whenever {result} is kUndefined.)
|
||||
static inline bool ComparisonResultToBool(RelationalComparisonMode mode,
|
||||
ComparisonResult result) {
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
return result == ComparisonResult::kLessThan;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
return result == ComparisonResult::kLessThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
return result == ComparisonResult::kGreaterThan;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
return result == ComparisonResult::kGreaterThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
bool ComparisonResultToBool(Operation op, ComparisonResult result);
|
||||
|
||||
class AbstractCode;
|
||||
class AccessorPair;
|
||||
|
@ -200,25 +200,6 @@ ComparisonResult BigInt::CompareToBigInt(Handle<BigInt> x, Handle<BigInt> y) {
|
||||
return ComparisonResult::kEqual;
|
||||
}
|
||||
|
||||
bool BigInt::CompareToBigIntReturnBool(RelationalComparisonMode mode,
|
||||
Handle<BigInt> x, Handle<BigInt> y) {
|
||||
ComparisonResult result = CompareToBigInt(x, y);
|
||||
DCHECK_NE(result, ComparisonResult::kUndefined);
|
||||
switch (mode) {
|
||||
case RelationalComparisonMode::kLessThan:
|
||||
return result == ComparisonResult::kLessThan;
|
||||
case RelationalComparisonMode::kLessThanOrEqual:
|
||||
return result == ComparisonResult::kLessThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
case RelationalComparisonMode::kGreaterThan:
|
||||
return result == ComparisonResult::kGreaterThan;
|
||||
case RelationalComparisonMode::kGreaterThanOrEqual:
|
||||
return result == ComparisonResult::kGreaterThan ||
|
||||
result == ComparisonResult::kEqual;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
bool BigInt::EqualToBigInt(BigInt* x, BigInt* y) {
|
||||
if (x->sign() != y->sign()) return false;
|
||||
if (x->length() != y->length()) return false;
|
||||
|
@ -38,8 +38,6 @@ class V8_EXPORT_PRIVATE BigInt : public HeapObject {
|
||||
Handle<BigInt> y);
|
||||
// More convenient version of "bool LessThan(x, y)".
|
||||
static ComparisonResult CompareToBigInt(Handle<BigInt> x, Handle<BigInt> y);
|
||||
static bool CompareToBigIntReturnBool(RelationalComparisonMode mode,
|
||||
Handle<BigInt> x, Handle<BigInt> y);
|
||||
static bool EqualToBigInt(BigInt* x, BigInt* y);
|
||||
static Handle<BigInt> BitwiseAnd(Handle<BigInt> x, Handle<BigInt> y);
|
||||
static Handle<BigInt> BitwiseXor(Handle<BigInt> x, Handle<BigInt> y);
|
||||
@ -58,8 +56,6 @@ class V8_EXPORT_PRIVATE BigInt : public HeapObject {
|
||||
static bool EqualToString(Handle<BigInt> x, Handle<String> y);
|
||||
static bool EqualToNumber(Handle<BigInt> x, Handle<Object> y);
|
||||
static ComparisonResult CompareToNumber(Handle<BigInt> x, Handle<Object> y);
|
||||
static bool CompareToNumberReturnBool(RelationalComparisonMode mode,
|
||||
Handle<BigInt> x, Handle<Object> y);
|
||||
// Exposed for tests, do not call directly. Use CompareToNumber() instead.
|
||||
static ComparisonResult CompareToDouble(Handle<BigInt> x, double y);
|
||||
|
||||
|
@ -247,10 +247,6 @@ class Token {
|
||||
|
||||
static bool IsBinaryOp(Value op) { return COMMA <= op && op <= EXP; }
|
||||
|
||||
static bool IsTruncatingBinaryOp(Value op) {
|
||||
return BIT_OR <= op && op <= SHR;
|
||||
}
|
||||
|
||||
static bool IsCompareOp(Value op) {
|
||||
return EQ <= op && op <= IN;
|
||||
}
|
||||
@ -263,62 +259,6 @@ class Token {
|
||||
return op == EQ || op == EQ_STRICT;
|
||||
}
|
||||
|
||||
static bool IsInequalityOp(Value op) {
|
||||
return op == NE || op == NE_STRICT;
|
||||
}
|
||||
|
||||
static bool IsArithmeticCompareOp(Value op) {
|
||||
return IsOrderedRelationalCompareOp(op) ||
|
||||
IsEqualityOp(op) || IsInequalityOp(op);
|
||||
}
|
||||
|
||||
static Value NegateCompareOp(Value op) {
|
||||
DCHECK(IsArithmeticCompareOp(op));
|
||||
switch (op) {
|
||||
case EQ: return NE;
|
||||
case NE: return EQ;
|
||||
case EQ_STRICT: return NE_STRICT;
|
||||
case NE_STRICT: return EQ_STRICT;
|
||||
case LT: return GTE;
|
||||
case GT: return LTE;
|
||||
case LTE: return GT;
|
||||
case GTE: return LT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static Value ReverseCompareOp(Value op) {
|
||||
DCHECK(IsArithmeticCompareOp(op));
|
||||
switch (op) {
|
||||
case EQ: return EQ;
|
||||
case NE: return NE;
|
||||
case EQ_STRICT: return EQ_STRICT;
|
||||
case NE_STRICT: return NE_STRICT;
|
||||
case LT: return GT;
|
||||
case GT: return LT;
|
||||
case LTE: return GTE;
|
||||
case GTE: return LTE;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static bool EvalComparison(Value op, double op1, double op2) {
|
||||
DCHECK(IsArithmeticCompareOp(op));
|
||||
switch (op) {
|
||||
case Token::EQ:
|
||||
case Token::EQ_STRICT: return (op1 == op2);
|
||||
case Token::NE: return (op1 != op2);
|
||||
case Token::LT: return (op1 < op2);
|
||||
case Token::GT: return (op1 > op2);
|
||||
case Token::LTE: return (op1 <= op2);
|
||||
case Token::GTE: return (op1 >= op2);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static Value BinaryOpForAssignment(Value op) {
|
||||
DCHECK(IsAssignmentOp(op));
|
||||
switch (op) {
|
||||
|
@ -56,9 +56,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return r7; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return r6; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return r8; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return r4; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return r3; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return r3; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return r6; }
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "src/counters.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects/bigint.h"
|
||||
#include "src/parsing/token.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -19,9 +18,8 @@ RUNTIME_FUNCTION(Runtime_BigIntCompareToBigInt) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Smi, mode, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(BigInt, lhs, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(BigInt, rhs, 2);
|
||||
bool result = ComparisonResultToBool(
|
||||
static_cast<RelationalComparisonMode>(mode->value()),
|
||||
BigInt::CompareToBigInt(lhs, rhs));
|
||||
bool result = ComparisonResultToBool(static_cast<Operation>(mode->value()),
|
||||
BigInt::CompareToBigInt(lhs, rhs));
|
||||
return *isolate->factory()->ToBoolean(result);
|
||||
}
|
||||
|
||||
@ -31,9 +29,8 @@ RUNTIME_FUNCTION(Runtime_BigIntCompareToNumber) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Smi, mode, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(BigInt, lhs, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 2);
|
||||
bool result = ComparisonResultToBool(
|
||||
static_cast<RelationalComparisonMode>(mode->value()),
|
||||
BigInt::CompareToNumber(lhs, rhs));
|
||||
bool result = ComparisonResultToBool(static_cast<Operation>(mode->value()),
|
||||
BigInt::CompareToNumber(lhs, rhs));
|
||||
return *isolate->factory()->ToBoolean(result);
|
||||
}
|
||||
|
||||
@ -77,6 +74,7 @@ RUNTIME_FUNCTION(Runtime_BigIntBinaryOp) {
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, left_obj, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, right_obj, 1);
|
||||
CONVERT_SMI_ARG_CHECKED(opcode, 2);
|
||||
Operation op = static_cast<Operation>(opcode);
|
||||
|
||||
if (!left_obj->IsBigInt() || !right_obj->IsBigInt()) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
@ -85,38 +83,38 @@ RUNTIME_FUNCTION(Runtime_BigIntBinaryOp) {
|
||||
Handle<BigInt> left(Handle<BigInt>::cast(left_obj));
|
||||
Handle<BigInt> right(Handle<BigInt>::cast(right_obj));
|
||||
MaybeHandle<BigInt> result;
|
||||
switch (opcode) {
|
||||
case Token::ADD:
|
||||
switch (op) {
|
||||
case Operation::kAdd:
|
||||
result = BigInt::Add(left, right);
|
||||
break;
|
||||
case Token::SUB:
|
||||
case Operation::kSubtract:
|
||||
result = BigInt::Subtract(left, right);
|
||||
break;
|
||||
case Token::MUL:
|
||||
case Operation::kMultiply:
|
||||
result = BigInt::Multiply(left, right);
|
||||
break;
|
||||
case Token::DIV:
|
||||
case Operation::kDivide:
|
||||
result = BigInt::Divide(left, right);
|
||||
break;
|
||||
case Token::MOD:
|
||||
case Operation::kModulus:
|
||||
result = BigInt::Remainder(left, right);
|
||||
break;
|
||||
case Token::BIT_AND:
|
||||
case Operation::kBitwiseAnd:
|
||||
result = BigInt::BitwiseAnd(left, right);
|
||||
break;
|
||||
case Token::BIT_OR:
|
||||
case Operation::kBitwiseOr:
|
||||
result = BigInt::BitwiseOr(left, right);
|
||||
break;
|
||||
case Token::BIT_XOR:
|
||||
case Operation::kBitwiseXor:
|
||||
result = BigInt::BitwiseXor(left, right);
|
||||
break;
|
||||
case Token::SHL:
|
||||
case Operation::kShiftLeft:
|
||||
result = BigInt::LeftShift(left, right);
|
||||
break;
|
||||
case Token::SAR:
|
||||
case Operation::kShiftRight:
|
||||
result = BigInt::SignedRightShift(left, right);
|
||||
break;
|
||||
case Token::SHR:
|
||||
case Operation::kShiftRightLogical:
|
||||
result = BigInt::UnsignedRightShift(left, right);
|
||||
break;
|
||||
default:
|
||||
@ -130,19 +128,20 @@ RUNTIME_FUNCTION(Runtime_BigIntUnaryOp) {
|
||||
DCHECK_EQ(2, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(BigInt, x, 0);
|
||||
CONVERT_SMI_ARG_CHECKED(opcode, 1);
|
||||
Operation op = static_cast<Operation>(opcode);
|
||||
|
||||
MaybeHandle<BigInt> result;
|
||||
switch (opcode) {
|
||||
case Token::BIT_NOT:
|
||||
switch (op) {
|
||||
case Operation::kBitwiseNot:
|
||||
result = BigInt::BitwiseNot(x);
|
||||
break;
|
||||
case Token::SUB:
|
||||
case Operation::kNegate:
|
||||
result = BigInt::UnaryMinus(x);
|
||||
break;
|
||||
case Token::INC:
|
||||
case Operation::kIncrement:
|
||||
result = BigInt::Increment(x);
|
||||
break;
|
||||
case Token::DEC:
|
||||
case Operation::kDecrement:
|
||||
result = BigInt::Decrement(x);
|
||||
break;
|
||||
default:
|
||||
|
@ -107,9 +107,11 @@ RUNTIME_FUNCTION(Runtime_NumberToSmi) {
|
||||
return isolate->heap()->nan_value();
|
||||
}
|
||||
|
||||
|
||||
// Compare two Smis as if they were converted to strings and then
|
||||
// compared lexicographically.
|
||||
// Compare two Smis x, y as if they were converted to strings and then
|
||||
// compared lexicographically. Returns:
|
||||
// -1 if x < y
|
||||
// 0 if x == y
|
||||
// 1 if x > y
|
||||
RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK_EQ(2, args.length());
|
||||
@ -117,12 +119,12 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
CONVERT_SMI_ARG_CHECKED(y_value, 1);
|
||||
|
||||
// If the integers are equal so are the string representations.
|
||||
if (x_value == y_value) return Smi::FromInt(EQUAL);
|
||||
if (x_value == y_value) return Smi::FromInt(0);
|
||||
|
||||
// If one of the integers is zero the normal integer order is the
|
||||
// same as the lexicographic order of the string representations.
|
||||
if (x_value == 0 || y_value == 0)
|
||||
return Smi::FromInt(x_value < y_value ? LESS : GREATER);
|
||||
return Smi::FromInt(x_value < y_value ? -1 : 1);
|
||||
|
||||
// If only one of the integers is negative the negative number is
|
||||
// smallest because the char code of '-' is less than the char code
|
||||
@ -133,8 +135,8 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
uint32_t x_scaled = x_value;
|
||||
uint32_t y_scaled = y_value;
|
||||
if (x_value < 0 || y_value < 0) {
|
||||
if (y_value >= 0) return Smi::FromInt(LESS);
|
||||
if (x_value >= 0) return Smi::FromInt(GREATER);
|
||||
if (y_value >= 0) return Smi::FromInt(-1);
|
||||
if (x_value >= 0) return Smi::FromInt(1);
|
||||
x_scaled = -x_value;
|
||||
y_scaled = -y_value;
|
||||
}
|
||||
@ -160,7 +162,7 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
int y_log10 = ((y_log2 + 1) * 1233) >> 12;
|
||||
y_log10 -= y_scaled < kPowersOf10[y_log10];
|
||||
|
||||
int tie = EQUAL;
|
||||
int tie = 0;
|
||||
|
||||
if (x_log10 < y_log10) {
|
||||
// X has fewer digits. We would like to simply scale up X but that
|
||||
@ -171,15 +173,15 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
// past the length of the shorter integer.
|
||||
x_scaled *= kPowersOf10[y_log10 - x_log10 - 1];
|
||||
y_scaled /= 10;
|
||||
tie = LESS;
|
||||
tie = -1;
|
||||
} else if (y_log10 < x_log10) {
|
||||
y_scaled *= kPowersOf10[x_log10 - y_log10 - 1];
|
||||
x_scaled /= 10;
|
||||
tie = GREATER;
|
||||
tie = 1;
|
||||
}
|
||||
|
||||
if (x_scaled < y_scaled) return Smi::FromInt(LESS);
|
||||
if (x_scaled > y_scaled) return Smi::FromInt(GREATER);
|
||||
if (x_scaled < y_scaled) return Smi::FromInt(-1);
|
||||
if (x_scaled > y_scaled) return Smi::FromInt(1);
|
||||
return Smi::FromInt(tie);
|
||||
}
|
||||
|
||||
|
@ -1123,32 +1123,6 @@ RUNTIME_FUNCTION(Runtime_SameValueZero) {
|
||||
return isolate->heap()->ToBoolean(x->SameValueZero(y));
|
||||
}
|
||||
|
||||
|
||||
// TODO(bmeurer): Kill this special wrapper and use TF compatible LessThan,
|
||||
// GreaterThan, etc. which return true or false.
|
||||
RUNTIME_FUNCTION(Runtime_Compare) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(3, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Object, ncr, 2);
|
||||
Maybe<ComparisonResult> result = Object::Compare(x, y);
|
||||
if (result.IsJust()) {
|
||||
switch (result.FromJust()) {
|
||||
case ComparisonResult::kLessThan:
|
||||
return Smi::FromInt(LESS);
|
||||
case ComparisonResult::kEqual:
|
||||
return Smi::FromInt(EQUAL);
|
||||
case ComparisonResult::kGreaterThan:
|
||||
return Smi::FromInt(GREATER);
|
||||
case ComparisonResult::kUndefined:
|
||||
return *ncr;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
return isolate->heap()->exception();
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_HasInPrototypeChain) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(2, args.length());
|
||||
|
@ -285,25 +285,6 @@ RUNTIME_FUNCTION(Runtime_StringCharCodeAt) {
|
||||
return Smi::FromInt(subject->Get(i));
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_StringCompare) {
|
||||
HandleScope handle_scope(isolate);
|
||||
DCHECK_EQ(2, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(String, x, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(String, y, 1);
|
||||
isolate->counters()->string_compare_runtime()->Increment();
|
||||
switch (String::Compare(x, y)) {
|
||||
case ComparisonResult::kLessThan:
|
||||
return Smi::FromInt(LESS);
|
||||
case ComparisonResult::kEqual:
|
||||
return Smi::FromInt(EQUAL);
|
||||
case ComparisonResult::kGreaterThan:
|
||||
return Smi::FromInt(GREATER);
|
||||
case ComparisonResult::kUndefined:
|
||||
break;
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_StringBuilderConcat) {
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(3, args.length());
|
||||
|
@ -429,7 +429,6 @@ namespace internal {
|
||||
F(ToName, 1, 1) \
|
||||
F(SameValue, 2, 1) \
|
||||
F(SameValueZero, 2, 1) \
|
||||
F(Compare, 3, 1) \
|
||||
F(HasInPrototypeChain, 2, 1) \
|
||||
F(CreateIterResultObject, 2, 1) \
|
||||
F(CreateDataProperty, 3, 1) \
|
||||
@ -534,7 +533,6 @@ namespace internal {
|
||||
F(StringAdd, 2, 1) \
|
||||
F(InternalizeString, 1, 1) \
|
||||
F(StringCharCodeAt, 2, 1) \
|
||||
F(StringCompare, 2, 1) \
|
||||
F(StringBuilderConcat, 3, 1) \
|
||||
F(StringBuilderJoin, 3, 1) \
|
||||
F(SparseJoinWithSeparator, 3, 1) \
|
||||
|
@ -56,9 +56,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return r6; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return r5; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return r7; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return r3; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return r2; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return r2; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return r5; }
|
||||
|
||||
|
@ -57,9 +57,6 @@ const Register StoreTransitionDescriptor::SlotRegister() { return rdi; }
|
||||
const Register StoreTransitionDescriptor::VectorRegister() { return rbx; }
|
||||
const Register StoreTransitionDescriptor::MapRegister() { return r11; }
|
||||
|
||||
const Register StringCompareDescriptor::LeftRegister() { return rdx; }
|
||||
const Register StringCompareDescriptor::RightRegister() { return rax; }
|
||||
|
||||
const Register ApiGetterDescriptor::HolderRegister() { return rcx; }
|
||||
const Register ApiGetterDescriptor::CallbackRegister() { return rbx; }
|
||||
|
||||
|
@ -106,16 +106,6 @@ TEST(StringAdd) {
|
||||
T.CheckCall(T.Val("bbb"), T.Val(""), T.Val("bbb"));
|
||||
}
|
||||
|
||||
|
||||
TEST(StringCompare) {
|
||||
FunctionTester T("(function(a,b) { return %_StringCompare(a,b); })", flags);
|
||||
|
||||
T.CheckCall(T.Val(-1), T.Val("aaa"), T.Val("bbb"));
|
||||
T.CheckCall(T.Val(0.0), T.Val("bbb"), T.Val("bbb"));
|
||||
T.CheckCall(T.Val(+1), T.Val("ccc"), T.Val("bbb"));
|
||||
}
|
||||
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -2685,9 +2685,9 @@ TEST(BranchIfNumericRelationalComparison) {
|
||||
{
|
||||
CodeStubAssembler m(asm_tester.state());
|
||||
Label return_true(&m), return_false(&m);
|
||||
m.BranchIfNumericRelationalComparison(
|
||||
RelationalComparisonMode::kGreaterThanOrEqual, m.Parameter(0),
|
||||
m.Parameter(1), &return_true, &return_false);
|
||||
m.BranchIfNumericRelationalComparison(Operation::kGreaterThanOrEqual,
|
||||
m.Parameter(0), m.Parameter(1),
|
||||
&return_true, &return_false);
|
||||
m.BIND(&return_true);
|
||||
m.Return(m.BooleanConstant(true));
|
||||
m.BIND(&return_false);
|
||||
|
@ -347,55 +347,80 @@ const six = BigInt(6);
|
||||
{
|
||||
let undef = Symbol();
|
||||
|
||||
assertEquals(%Compare(zero, zero, undef), 0);
|
||||
assertTrue(%Equal(zero, zero));
|
||||
assertTrue(%GreaterThanOrEqual(zero, zero));
|
||||
|
||||
assertEquals(%Compare(zero, one, undef), -1);
|
||||
assertEquals(%Compare(one, zero, undef), +1);
|
||||
assertTrue(%LessThan(zero, one));
|
||||
assertTrue(%GreaterThan(one, zero));
|
||||
|
||||
assertEquals(%Compare(minus_one, one, undef), -1);
|
||||
assertEquals(%Compare(one, minus_one, undef), +1);
|
||||
assertTrue(%LessThan(minus_one, one));
|
||||
assertTrue(%GreaterThan(one, minus_one));
|
||||
|
||||
assertEquals(%Compare(zero, -0, undef), 0);
|
||||
assertEquals(%Compare(-0, zero, undef), 0);
|
||||
assertTrue(%Equal(zero, -0));
|
||||
assertTrue(%LessThanOrEqual(zero, -0));
|
||||
assertTrue(%GreaterThanOrEqual(zero, -0));
|
||||
assertTrue(%Equal(-0, zero));
|
||||
assertTrue(%LessThanOrEqual(-0, zero));
|
||||
assertTrue(%GreaterThanOrEqual(-0, zero));
|
||||
|
||||
assertEquals(%Compare(zero, 0, undef), 0);
|
||||
assertEquals(%Compare(0, zero, undef), 0);
|
||||
assertTrue(%Equal(zero, 0));
|
||||
assertTrue(%Equal(0, zero));
|
||||
|
||||
assertEquals(%Compare(minus_one, 1, undef), -1);
|
||||
assertEquals(%Compare(1, minus_one, undef), +1);
|
||||
assertTrue(%LessThan(minus_one, 1));
|
||||
assertTrue(%GreaterThan(1, minus_one));
|
||||
|
||||
assertEquals(%Compare(six, NaN, undef), undef);
|
||||
assertEquals(%Compare(NaN, six, undef), undef);
|
||||
assertFalse(%LessThan(six, NaN));
|
||||
assertFalse(%GreaterThan(six, NaN));
|
||||
assertFalse(%Equal(six, NaN));
|
||||
assertFalse(%LessThan(NaN, six));
|
||||
assertFalse(%GreaterThan(NaN, six));
|
||||
assertFalse(%Equal(NaN, six));
|
||||
|
||||
assertEquals(%Compare(six, Infinity, undef), -1);
|
||||
assertEquals(%Compare(Infinity, six, undef), +1);
|
||||
assertTrue(%LessThan(six, Infinity));
|
||||
assertTrue(%GreaterThan(Infinity, six));
|
||||
|
||||
assertEquals(%Compare(six, -Infinity, undef), +1);
|
||||
assertEquals(%Compare(-Infinity, six, undef), -1);
|
||||
assertTrue(%GreaterThan(six, -Infinity));
|
||||
assertTrue(%LessThan(-Infinity, six));
|
||||
|
||||
assertEquals(%Compare(six, 5.99999999, undef), +1);
|
||||
assertEquals(%Compare(5.99999999, six, undef), -1);
|
||||
assertTrue(%GreaterThan(six, 5.99999999));
|
||||
assertTrue(%LessThan(5.99999999, six));
|
||||
|
||||
assertEquals(%Compare(zero, "", undef), 0);
|
||||
assertEquals(%Compare("", zero, undef), 0);
|
||||
assertTrue(%Equal(zero, ""));
|
||||
assertTrue(%LessThanOrEqual(zero, ""));
|
||||
assertTrue(%GreaterThanOrEqual(zero, ""));
|
||||
assertTrue(%Equal("", zero));
|
||||
assertTrue(%LessThanOrEqual("", zero));
|
||||
assertTrue(%GreaterThanOrEqual("", zero));
|
||||
|
||||
assertEquals(%Compare(minus_one, "\t-1 ", undef), 0);
|
||||
assertEquals(%Compare("\t-1 ", minus_one, undef), 0);
|
||||
assertTrue(%Equal(minus_one, "\t-1 "));
|
||||
assertTrue(%LessThanOrEqual(minus_one, "\t-1 "));
|
||||
assertTrue(%GreaterThanOrEqual(minus_one, "\t-1 "));
|
||||
assertTrue(%Equal("\t-1 ", minus_one));
|
||||
assertTrue(%LessThanOrEqual("\t-1 ", minus_one));
|
||||
assertTrue(%GreaterThanOrEqual("\t-1 ", minus_one));
|
||||
|
||||
assertEquals(%Compare(minus_one, "-0x1", undef), undef);
|
||||
assertEquals(%Compare("-0x1", minus_one, undef), undef);
|
||||
assertFalse(%LessThan(minus_one, "-0x1"));
|
||||
assertFalse(%GreaterThan(minus_one, "-0x1"));
|
||||
assertFalse(%Equal(minus_one, "-0x1"));
|
||||
assertFalse(%LessThan("-0x1", minus_one));
|
||||
assertFalse(%GreaterThan("-0x1", minus_one));
|
||||
assertFalse(%Equal("-0x1", minus_one));
|
||||
|
||||
const unsafe = "9007199254740993"; // 2**53 + 1
|
||||
assertEquals(%Compare(BigInt.parseInt(unsafe), unsafe, undef), +1);
|
||||
assertEquals(%Compare(unsafe, BigInt.parseInt(unsafe), undef), -1);
|
||||
assertTrue(%GreaterThan(BigInt.parseInt(unsafe), unsafe));
|
||||
assertTrue(%LessThan(unsafe, BigInt.parseInt(unsafe)));
|
||||
|
||||
assertThrows(() => %Compare(six, Symbol(6), undef), TypeError);
|
||||
assertThrows(() => %Compare(Symbol(6), six, undef), TypeError);
|
||||
assertThrows(() => %LessThan(six, Symbol(6)), TypeError);
|
||||
assertThrows(() => %LessThan(Symbol(6), six), TypeError);
|
||||
|
||||
assertEquals(%Compare(six, {valueOf() {return Object(5)},
|
||||
toString() {return 6}}, undef), 0);
|
||||
assertEquals(%Compare({valueOf() {return Object(5)},
|
||||
toString() {return 6}}, six, undef), 0);
|
||||
var value_five_string_six = {
|
||||
valueOf() { return Object(5); },
|
||||
toString() { return 6; }
|
||||
};
|
||||
assertTrue(%LessThanOrEqual(six, value_five_string_six));
|
||||
assertTrue(%GreaterThanOrEqual(six, value_five_string_six));
|
||||
assertTrue(%LessThanOrEqual(value_five_string_six, six));
|
||||
assertTrue(%GreaterThanOrEqual(value_five_string_six, six));
|
||||
}{
|
||||
assertFalse(zero < zero);
|
||||
assertTrue(zero <= zero);
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
// Flags: --allow-natives-syntax --cache=code
|
||||
|
||||
assertEquals(-1, %StringCompare("a", "b"));
|
||||
assertTrue(%StringLessThan("a", "b"));
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
assertEquals(-1, %StringCompare("abc\u0102", "abc\u0201"));
|
||||
assertTrue(%StringLessThan("abc\u0102", "abc\u0201"));
|
||||
|
Loading…
Reference in New Issue
Block a user