Interpreter tester should accept metadata instead of a vector
The InterpreterTester class cobbles together a JSFunction from a manually created bytecode and feedback vector. However it's fragile against design changes in the way literal arrays and feedback vectors are handled. It's better to let it hand in a feedback vector metadata object, and allow the system to create the vector from that. BUG=v8:5456 Review-Url: https://codereview.chromium.org/2652893010 Cr-Commit-Position: refs/heads/master@{#42684}
This commit is contained in:
parent
a5e7382d84
commit
d24ce605c9
@ -18,24 +18,25 @@ MaybeHandle<Object> CallInterpreter(Isolate* isolate,
|
||||
|
||||
InterpreterTester::InterpreterTester(
|
||||
Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode,
|
||||
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter)
|
||||
MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
|
||||
: isolate_(isolate),
|
||||
source_(source),
|
||||
bytecode_(bytecode),
|
||||
feedback_vector_(feedback_vector) {
|
||||
feedback_metadata_(feedback_metadata) {
|
||||
i::FLAG_ignition = true;
|
||||
i::FLAG_always_opt = false;
|
||||
}
|
||||
|
||||
InterpreterTester::InterpreterTester(
|
||||
Isolate* isolate, Handle<BytecodeArray> bytecode,
|
||||
MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter)
|
||||
: InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {}
|
||||
MaybeHandle<TypeFeedbackMetadata> feedback_metadata, const char* filter)
|
||||
: InterpreterTester(isolate, nullptr, bytecode, feedback_metadata, filter) {
|
||||
}
|
||||
|
||||
InterpreterTester::InterpreterTester(Isolate* isolate, const char* source,
|
||||
const char* filter)
|
||||
: InterpreterTester(isolate, source, MaybeHandle<BytecodeArray>(),
|
||||
MaybeHandle<TypeFeedbackVector>(), filter) {}
|
||||
MaybeHandle<TypeFeedbackMetadata>(), filter) {}
|
||||
|
||||
InterpreterTester::~InterpreterTester() {}
|
||||
|
||||
|
@ -39,6 +39,8 @@ class InterpreterCallable {
|
||||
return CallInterpreter(isolate_, function_, args...);
|
||||
}
|
||||
|
||||
TypeFeedbackVector* vector() const { return function_->feedback_vector(); }
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
Handle<JSFunction> function_;
|
||||
@ -52,12 +54,12 @@ class InterpreterTester {
|
||||
public:
|
||||
InterpreterTester(Isolate* isolate, const char* source,
|
||||
MaybeHandle<BytecodeArray> bytecode,
|
||||
MaybeHandle<TypeFeedbackVector> feedback_vector,
|
||||
MaybeHandle<TypeFeedbackMetadata> feedback_metadata,
|
||||
const char* filter);
|
||||
|
||||
InterpreterTester(Isolate* isolate, Handle<BytecodeArray> bytecode,
|
||||
MaybeHandle<TypeFeedbackVector> feedback_vector =
|
||||
MaybeHandle<TypeFeedbackVector>(),
|
||||
MaybeHandle<TypeFeedbackMetadata> feedback_metadata =
|
||||
MaybeHandle<TypeFeedbackMetadata>(),
|
||||
const char* filter = kFunctionName);
|
||||
|
||||
InterpreterTester(Isolate* isolate, const char* source,
|
||||
@ -84,7 +86,7 @@ class InterpreterTester {
|
||||
Isolate* isolate_;
|
||||
const char* source_;
|
||||
MaybeHandle<BytecodeArray> bytecode_;
|
||||
MaybeHandle<TypeFeedbackVector> feedback_vector_;
|
||||
MaybeHandle<TypeFeedbackMetadata> feedback_metadata_;
|
||||
|
||||
template <class... A>
|
||||
Handle<JSFunction> GetBytecodeFunction() {
|
||||
@ -114,9 +116,13 @@ class InterpreterTester {
|
||||
if (!bytecode_.is_null()) {
|
||||
function->shared()->set_function_data(*bytecode_.ToHandleChecked());
|
||||
}
|
||||
if (!feedback_vector_.is_null()) {
|
||||
function->literals()->set_feedback_vector(
|
||||
*feedback_vector_.ToHandleChecked());
|
||||
if (!feedback_metadata_.is_null()) {
|
||||
// TODO(mvstanton): The call to ClearOptimizedCodeMap can be removed
|
||||
// when we stop storing literals in the optimized code map (upcoming CL).
|
||||
function->shared()->ClearOptimizedCodeMap();
|
||||
function->shared()->set_feedback_metadata(
|
||||
*feedback_metadata_.ToHandleChecked());
|
||||
JSFunction::EnsureLiterals(function);
|
||||
}
|
||||
return function;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace interpreter {
|
||||
|
||||
static int GetIndex(FeedbackVectorSlot slot) {
|
||||
return TypeFeedbackVector::GetIndex(slot);
|
||||
}
|
||||
|
||||
TEST(InterpreterReturn) {
|
||||
HandleAndZoneScope handles;
|
||||
@ -272,8 +275,8 @@ TEST(InterpreterShiftOpsSmi) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
int lhs = lhs_inputs[l];
|
||||
@ -281,11 +284,11 @@ TEST(InterpreterShiftOpsSmi) {
|
||||
builder.LoadLiteral(Smi::FromInt(lhs))
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(Smi::FromInt(rhs))
|
||||
.BinaryOperation(kShiftOperators[o], reg, vector->GetIndex(slot))
|
||||
.BinaryOperation(kShiftOperators[o], reg, GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
Handle<Object> expected_value =
|
||||
@ -311,8 +314,8 @@ TEST(InterpreterBinaryOpsSmi) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
int lhs = lhs_inputs[l];
|
||||
@ -320,12 +323,11 @@ TEST(InterpreterBinaryOpsSmi) {
|
||||
builder.LoadLiteral(Smi::FromInt(lhs))
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(Smi::FromInt(rhs))
|
||||
.BinaryOperation(kArithmeticOperators[o], reg,
|
||||
vector->GetIndex(slot))
|
||||
.BinaryOperation(kArithmeticOperators[o], reg, GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
Handle<Object> expected_value =
|
||||
@ -352,8 +354,8 @@ TEST(InterpreterBinaryOpsHeapNumber) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
double lhs = lhs_inputs[l];
|
||||
@ -361,12 +363,11 @@ TEST(InterpreterBinaryOpsHeapNumber) {
|
||||
builder.LoadLiteral(factory->NewNumber(lhs))
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(factory->NewNumber(rhs))
|
||||
.BinaryOperation(kArithmeticOperators[o], reg,
|
||||
vector->GetIndex(slot))
|
||||
.BinaryOperation(kArithmeticOperators[o], reg, GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
Handle<Object> expected_value =
|
||||
@ -424,23 +425,23 @@ TEST(InterpreterStringAdd) {
|
||||
BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
builder.LoadLiteral(test_cases[i].lhs)
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(test_cases[i].rhs)
|
||||
.BinaryOperation(Token::Value::ADD, reg, vector->GetIndex(slot))
|
||||
.BinaryOperation(Token::Value::ADD, reg, GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->SameValue(*test_cases[i].expected_value));
|
||||
|
||||
Object* feedback = vector->Get(slot);
|
||||
Object* feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(test_cases[i].expected_feedback,
|
||||
static_cast<Smi*>(feedback)->value());
|
||||
@ -486,28 +487,21 @@ TEST(InterpreterParameter8) {
|
||||
FeedbackVectorSlot slot5 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
FeedbackVectorSlot slot6 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
builder.LoadAccumulatorWithRegister(builder.Parameter(0))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(1),
|
||||
vector->GetIndex(slot))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(2),
|
||||
vector->GetIndex(slot1))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(3),
|
||||
vector->GetIndex(slot2))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(4),
|
||||
vector->GetIndex(slot3))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(5),
|
||||
vector->GetIndex(slot4))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(6),
|
||||
vector->GetIndex(slot5))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(7),
|
||||
vector->GetIndex(slot6))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(1), GetIndex(slot))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(2), GetIndex(slot1))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(3), GetIndex(slot2))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(4), GetIndex(slot3))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(5), GetIndex(slot4))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(6), GetIndex(slot5))
|
||||
.BinaryOperation(Token::Value::ADD, builder.Parameter(7), GetIndex(slot6))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
typedef Handle<Object> H;
|
||||
auto callable = tester.GetCallable<H, H, H, H, H, H, H, H>();
|
||||
|
||||
@ -653,23 +647,23 @@ TEST(InterpreterBinaryOpTypeFeedback) {
|
||||
i::FeedbackVectorSpec feedback_spec(&zone);
|
||||
i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
i::NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
i::NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
builder.LoadLiteral(test_case.arg1)
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(test_case.arg2)
|
||||
.BinaryOperation(test_case.op, reg, vector->GetIndex(slot0))
|
||||
.BinaryOperation(test_case.op, reg, GetIndex(slot0))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
|
||||
Handle<Object> return_val = callable().ToHandleChecked();
|
||||
Object* feedback0 = vector->Get(slot0);
|
||||
Object* feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(test_case.feedback, static_cast<Smi*>(feedback0)->value());
|
||||
CHECK(Object::Equals(test_case.result, return_val).ToChecked());
|
||||
@ -757,23 +751,23 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) {
|
||||
i::FeedbackVectorSpec feedback_spec(&zone);
|
||||
i::FeedbackVectorSlot slot0 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
i::NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
i::NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0);
|
||||
builder.LoadLiteral(test_case.arg1)
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadLiteral(Smi::FromInt(test_case.arg2))
|
||||
.BinaryOperation(test_case.op, reg, vector->GetIndex(slot0))
|
||||
.BinaryOperation(test_case.op, reg, GetIndex(slot0))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
|
||||
Handle<Object> return_val = callable().ToHandleChecked();
|
||||
Object* feedback0 = vector->Get(slot0);
|
||||
Object* feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(test_case.feedback, static_cast<Smi*>(feedback0)->value());
|
||||
CHECK(Object::Equals(test_case.result, return_val).ToChecked());
|
||||
@ -810,22 +804,22 @@ TEST(InterpreterUnaryOpFeedback) {
|
||||
i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
i::FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
i::NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
i::NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
builder.LoadAccumulatorWithRegister(builder.Parameter(0))
|
||||
.CountOperation(test_case.op, vector->GetIndex(slot0))
|
||||
.CountOperation(test_case.op, GetIndex(slot0))
|
||||
.LoadAccumulatorWithRegister(builder.Parameter(1))
|
||||
.CountOperation(test_case.op, vector->GetIndex(slot1))
|
||||
.CountOperation(test_case.op, GetIndex(slot1))
|
||||
.LoadAccumulatorWithRegister(builder.Parameter(2))
|
||||
.CountOperation(test_case.op, vector->GetIndex(slot2))
|
||||
.CountOperation(test_case.op, GetIndex(slot2))
|
||||
.LoadAccumulatorWithRegister(builder.Parameter(3))
|
||||
.CountOperation(test_case.op, vector->GetIndex(slot3))
|
||||
.CountOperation(test_case.op, GetIndex(slot3))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
typedef Handle<Object> H;
|
||||
auto callable = tester.GetCallable<H, H, H, H>();
|
||||
|
||||
@ -835,22 +829,22 @@ TEST(InterpreterUnaryOpFeedback) {
|
||||
test_case.number_feedback_value, test_case.any_feedback_value)
|
||||
.ToHandleChecked();
|
||||
USE(return_val);
|
||||
Object* feedback0 = vector->Get(slot0);
|
||||
Object* feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
|
||||
static_cast<Smi*>(feedback0)->value());
|
||||
|
||||
Object* feedback1 = vector->Get(slot1);
|
||||
Object* feedback1 = callable.vector()->Get(slot1);
|
||||
CHECK(feedback1->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber,
|
||||
static_cast<Smi*>(feedback1)->value());
|
||||
|
||||
Object* feedback2 = vector->Get(slot2);
|
||||
Object* feedback2 = callable.vector()->Get(slot2);
|
||||
CHECK(feedback2->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber,
|
||||
static_cast<Smi*>(feedback2)->value());
|
||||
|
||||
Object* feedback3 = vector->Get(slot3);
|
||||
Object* feedback3 = callable.vector()->Get(slot3);
|
||||
CHECK(feedback3->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kAny,
|
||||
static_cast<Smi*>(feedback3)->value());
|
||||
@ -873,18 +867,18 @@ TEST(InterpreterBitwiseTypeFeedback) {
|
||||
i::FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
i::FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
i::NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
i::NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
builder.LoadAccumulatorWithRegister(builder.Parameter(0))
|
||||
.BinaryOperation(op, builder.Parameter(1), vector->GetIndex(slot0))
|
||||
.BinaryOperation(op, builder.Parameter(2), vector->GetIndex(slot1))
|
||||
.BinaryOperation(op, builder.Parameter(3), vector->GetIndex(slot2))
|
||||
.BinaryOperation(op, builder.Parameter(1), GetIndex(slot0))
|
||||
.BinaryOperation(op, builder.Parameter(2), GetIndex(slot1))
|
||||
.BinaryOperation(op, builder.Parameter(3), GetIndex(slot2))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
typedef Handle<Object> H;
|
||||
auto callable = tester.GetCallable<H, H, H, H>();
|
||||
|
||||
@ -896,17 +890,17 @@ TEST(InterpreterBitwiseTypeFeedback) {
|
||||
Handle<Object> return_val =
|
||||
callable(arg1, arg2, arg3, arg4).ToHandleChecked();
|
||||
USE(return_val);
|
||||
Object* feedback0 = vector->Get(slot0);
|
||||
Object* feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
|
||||
static_cast<Smi*>(feedback0)->value());
|
||||
|
||||
Object* feedback1 = vector->Get(slot1);
|
||||
Object* feedback1 = callable.vector()->Get(slot1);
|
||||
CHECK(feedback1->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber,
|
||||
static_cast<Smi*>(feedback1)->value());
|
||||
|
||||
Object* feedback2 = vector->Get(slot2);
|
||||
Object* feedback2 = callable.vector()->Get(slot2);
|
||||
CHECK(feedback2->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kAny,
|
||||
static_cast<Smi*>(feedback2)->value());
|
||||
@ -1041,19 +1035,19 @@ TEST(InterpreterLoadNamedProperty) {
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Handle<i::String> name = factory->NewStringFromAsciiChecked("val");
|
||||
name = factory->string_table()->LookupString(isolate, name);
|
||||
|
||||
BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0);
|
||||
|
||||
builder.LoadNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot))
|
||||
builder.LoadNamedProperty(builder.Parameter(0), name, GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })");
|
||||
@ -1094,8 +1088,8 @@ TEST(InterpreterLoadKeyedProperty) {
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddKeyedLoadICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Handle<i::String> key = factory->NewStringFromAsciiChecked("key");
|
||||
key = factory->string_table()->LookupString(isolate, key);
|
||||
@ -1103,11 +1097,11 @@ TEST(InterpreterLoadKeyedProperty) {
|
||||
BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
|
||||
|
||||
builder.LoadLiteral(key)
|
||||
.LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot))
|
||||
.LoadKeyedProperty(builder.Parameter(0), GetIndex(slot))
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject("({ key : 123 })");
|
||||
@ -1136,8 +1130,8 @@ TEST(InterpreterStoreNamedProperty) {
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Handle<i::String> name = factory->NewStringFromAsciiChecked("val");
|
||||
name = factory->string_table()->LookupString(isolate, name);
|
||||
@ -1145,12 +1139,11 @@ TEST(InterpreterStoreNamedProperty) {
|
||||
BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0);
|
||||
|
||||
builder.LoadLiteral(Smi::FromInt(999))
|
||||
.StoreNamedProperty(builder.Parameter(0), name, vector->GetIndex(slot),
|
||||
STRICT)
|
||||
.StoreNamedProperty(builder.Parameter(0), name, GetIndex(slot), STRICT)
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })");
|
||||
// Test IC miss.
|
||||
@ -1195,8 +1188,8 @@ TEST(InterpreterStoreKeyedProperty) {
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddKeyedStoreICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Handle<i::String> name = factory->NewStringFromAsciiChecked("val");
|
||||
name = factory->string_table()->LookupString(isolate, name);
|
||||
@ -1206,12 +1199,12 @@ TEST(InterpreterStoreKeyedProperty) {
|
||||
builder.LoadLiteral(name)
|
||||
.StoreAccumulatorInRegister(Register(0))
|
||||
.LoadLiteral(Smi::FromInt(999))
|
||||
.StoreKeyedProperty(builder.Parameter(0), Register(0),
|
||||
vector->GetIndex(slot), i::SLOPPY)
|
||||
.StoreKeyedProperty(builder.Parameter(0), Register(0), GetIndex(slot),
|
||||
i::SLOPPY)
|
||||
.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
Handle<Object> object = InterpreterTester::NewObject("({ val : 123 })");
|
||||
// Test IC miss.
|
||||
@ -1243,11 +1236,11 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) {
|
||||
FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
|
||||
FeedbackVectorSlot call_slot = feedback_spec.AddCallICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
int slot_index = vector->GetIndex(slot);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
int slot_index = GetIndex(slot);
|
||||
int call_slot_index = -1;
|
||||
call_slot_index = vector->GetIndex(call_slot);
|
||||
call_slot_index = GetIndex(call_slot);
|
||||
|
||||
Handle<i::String> name = factory->NewStringFromAsciiChecked("func");
|
||||
name = factory->string_table()->LookupString(isolate, name);
|
||||
@ -1266,7 +1259,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) {
|
||||
builder.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject(
|
||||
@ -1287,7 +1280,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) {
|
||||
builder.Return();
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject(
|
||||
@ -1320,7 +1313,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) {
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject(
|
||||
@ -1368,7 +1361,7 @@ static void TestInterpreterCall(TailCallMode tail_call_mode) {
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<Handle<Object>>();
|
||||
|
||||
Handle<Object> object = InterpreterTester::NewObject(
|
||||
@ -1421,8 +1414,8 @@ TEST(InterpreterJumps) {
|
||||
FeedbackVectorSlot slot1 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
FeedbackVectorSlot slot2 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0), scratch(1);
|
||||
BytecodeLabel label[3];
|
||||
@ -1431,18 +1424,17 @@ TEST(InterpreterJumps) {
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.Jump(&label[1]);
|
||||
SetRegister(builder, reg, 1024, scratch).Bind(&label[0]);
|
||||
IncrementRegister(builder, reg, 1, scratch, vector->GetIndex(slot))
|
||||
.Jump(&label[2]);
|
||||
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot)).Jump(&label[2]);
|
||||
SetRegister(builder, reg, 2048, scratch).Bind(&label[1]);
|
||||
IncrementRegister(builder, reg, 2, scratch, vector->GetIndex(slot1))
|
||||
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot1))
|
||||
.JumpLoop(&label[0], 0);
|
||||
SetRegister(builder, reg, 4096, scratch).Bind(&label[2]);
|
||||
IncrementRegister(builder, reg, 4, scratch, vector->GetIndex(slot2))
|
||||
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot2))
|
||||
.LoadAccumulatorWithRegister(reg)
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
@ -1462,8 +1454,8 @@ TEST(InterpreterConditionalJumps) {
|
||||
FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0), scratch(1);
|
||||
BytecodeLabel label[2];
|
||||
@ -1473,26 +1465,26 @@ TEST(InterpreterConditionalJumps) {
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadFalse()
|
||||
.JumpIfFalse(&label[0]);
|
||||
IncrementRegister(builder, reg, 1024, scratch, vector->GetIndex(slot))
|
||||
IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot))
|
||||
.Bind(&label[0])
|
||||
.LoadTrue()
|
||||
.JumpIfFalse(&done);
|
||||
IncrementRegister(builder, reg, 1, scratch, vector->GetIndex(slot1))
|
||||
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1))
|
||||
.LoadTrue()
|
||||
.JumpIfTrue(&label[1]);
|
||||
IncrementRegister(builder, reg, 2048, scratch, vector->GetIndex(slot2))
|
||||
IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2))
|
||||
.Bind(&label[1]);
|
||||
IncrementRegister(builder, reg, 2, scratch, vector->GetIndex(slot3))
|
||||
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3))
|
||||
.LoadFalse()
|
||||
.JumpIfTrue(&done1);
|
||||
IncrementRegister(builder, reg, 4, scratch, vector->GetIndex(slot4))
|
||||
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4))
|
||||
.LoadAccumulatorWithRegister(reg)
|
||||
.Bind(&done)
|
||||
.Bind(&done1)
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
@ -1512,8 +1504,8 @@ TEST(InterpreterConditionalJumps2) {
|
||||
FeedbackVectorSlot slot3 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
FeedbackVectorSlot slot4 = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0), scratch(1);
|
||||
BytecodeLabel label[2];
|
||||
@ -1523,26 +1515,26 @@ TEST(InterpreterConditionalJumps2) {
|
||||
.StoreAccumulatorInRegister(reg)
|
||||
.LoadFalse()
|
||||
.JumpIfFalse(&label[0]);
|
||||
IncrementRegister(builder, reg, 1024, scratch, vector->GetIndex(slot))
|
||||
IncrementRegister(builder, reg, 1024, scratch, GetIndex(slot))
|
||||
.Bind(&label[0])
|
||||
.LoadTrue()
|
||||
.JumpIfFalse(&done);
|
||||
IncrementRegister(builder, reg, 1, scratch, vector->GetIndex(slot1))
|
||||
IncrementRegister(builder, reg, 1, scratch, GetIndex(slot1))
|
||||
.LoadTrue()
|
||||
.JumpIfTrue(&label[1]);
|
||||
IncrementRegister(builder, reg, 2048, scratch, vector->GetIndex(slot2))
|
||||
IncrementRegister(builder, reg, 2048, scratch, GetIndex(slot2))
|
||||
.Bind(&label[1]);
|
||||
IncrementRegister(builder, reg, 2, scratch, vector->GetIndex(slot3))
|
||||
IncrementRegister(builder, reg, 2, scratch, GetIndex(slot3))
|
||||
.LoadFalse()
|
||||
.JumpIfTrue(&done1);
|
||||
IncrementRegister(builder, reg, 4, scratch, vector->GetIndex(slot4))
|
||||
IncrementRegister(builder, reg, 4, scratch, GetIndex(slot4))
|
||||
.LoadAccumulatorWithRegister(reg)
|
||||
.Bind(&done)
|
||||
.Bind(&done1)
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
@ -1557,8 +1549,8 @@ TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register reg(0), scratch(256);
|
||||
BytecodeLabel done, fake;
|
||||
@ -1568,7 +1560,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
// Consume all 8-bit operands
|
||||
for (int i = 1; i <= 256; i++) {
|
||||
builder.LoadLiteral(isolate->factory()->NewNumber(i));
|
||||
builder.BinaryOperation(Token::Value::ADD, reg, vector->GetIndex(slot));
|
||||
builder.BinaryOperation(Token::Value::ADD, reg, GetIndex(slot));
|
||||
builder.StoreAccumulatorInRegister(reg);
|
||||
}
|
||||
builder.Jump(&done);
|
||||
@ -1578,7 +1570,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
for (int i = 0; i < 6600; i++) {
|
||||
builder.LoadLiteral(Smi::kZero); // 1-byte
|
||||
builder.BinaryOperation(Token::Value::ADD, scratch,
|
||||
vector->GetIndex(slot)); // 6-bytes
|
||||
GetIndex(slot)); // 6-bytes
|
||||
builder.StoreAccumulatorInRegister(scratch); // 4-bytes
|
||||
builder.MoveRegister(scratch, reg); // 6-bytes
|
||||
}
|
||||
@ -1600,7 +1592,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
}
|
||||
CHECK(found_16bit_constant_jump);
|
||||
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 256.0 / 2 * (1 + 256));
|
||||
@ -1703,24 +1695,24 @@ TEST(InterpreterSmiComparisons) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register r0(0);
|
||||
builder.LoadLiteral(Smi::FromInt(inputs[i]))
|
||||
.StoreAccumulatorInRegister(r0)
|
||||
.LoadLiteral(Smi::FromInt(inputs[j]))
|
||||
.CompareOperation(comparison, r0, vector->GetIndex(slot))
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
Object* feedback = vector->Get(slot);
|
||||
Object* feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(CompareOperationFeedback::kSignedSmall,
|
||||
static_cast<Smi*>(feedback)->value());
|
||||
@ -1750,24 +1742,24 @@ TEST(InterpreterHeapNumberComparisons) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register r0(0);
|
||||
builder.LoadLiteral(factory->NewHeapNumber(inputs[i]))
|
||||
.StoreAccumulatorInRegister(r0)
|
||||
.LoadLiteral(factory->NewHeapNumber(inputs[j]))
|
||||
.CompareOperation(comparison, r0, vector->GetIndex(slot))
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
Object* feedback = vector->Get(slot);
|
||||
Object* feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(CompareOperationFeedback::kNumber,
|
||||
static_cast<Smi*>(feedback)->value());
|
||||
@ -1795,25 +1787,25 @@ TEST(InterpreterStringComparisons) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
BytecodeArrayBuilder builder(isolate, handles.main_zone(), 0, 0, 1);
|
||||
Register r0(0);
|
||||
builder.LoadLiteral(factory->InternalizeUtf8String(lhs))
|
||||
.StoreAccumulatorInRegister(r0)
|
||||
.LoadLiteral(factory->InternalizeUtf8String(rhs))
|
||||
.CompareOperation(comparison, r0, vector->GetIndex(slot))
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
|
||||
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
Object* feedback = vector->Get(slot);
|
||||
Object* feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
int const expected_feedback =
|
||||
Token::IsOrderedRelationalCompareOp(comparison)
|
||||
@ -1854,8 +1846,8 @@ TEST(InterpreterMixedComparisons) {
|
||||
|
||||
FeedbackVectorSpec feedback_spec(&zone);
|
||||
FeedbackVectorSlot slot = feedback_spec.AddInterpreterCompareICSlot();
|
||||
Handle<i::TypeFeedbackVector> vector =
|
||||
NewTypeFeedbackVector(isolate, &feedback_spec);
|
||||
Handle<i::TypeFeedbackMetadata> metadata =
|
||||
NewTypeFeedbackMetadata(isolate, &feedback_spec);
|
||||
|
||||
Register r0(0);
|
||||
if (pass == 0) {
|
||||
@ -1863,26 +1855,26 @@ TEST(InterpreterMixedComparisons) {
|
||||
builder.LoadLiteral(factory->NewNumber(lhs))
|
||||
.StoreAccumulatorInRegister(r0)
|
||||
.LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr))
|
||||
.CompareOperation(comparison, r0, vector->GetIndex(slot))
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
} else {
|
||||
// Comparison with HeapNumber on the rhs and String on the lhs
|
||||
builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr))
|
||||
.StoreAccumulatorInRegister(r0)
|
||||
.LoadLiteral(factory->NewNumber(rhs))
|
||||
.CompareOperation(comparison, r0, vector->GetIndex(slot))
|
||||
.CompareOperation(comparison, r0, GetIndex(slot))
|
||||
.Return();
|
||||
}
|
||||
|
||||
Handle<BytecodeArray> bytecode_array =
|
||||
builder.ToBytecodeArray(isolate);
|
||||
InterpreterTester tester(isolate, bytecode_array, vector);
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(),
|
||||
CompareC(comparison, lhs, rhs, true));
|
||||
Object* feedback = vector->Get(slot);
|
||||
Object* feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
// kNumber | kString gets converted to CompareOperationHint::kAny.
|
||||
int expected_feedback = CompareOperationFeedback::kNumber |
|
||||
|
@ -46,6 +46,11 @@ Handle<TypeFeedbackVector> NewTypeFeedbackVector(Isolate* isolate, Spec* spec) {
|
||||
return TypeFeedbackVector::New(isolate, metadata);
|
||||
}
|
||||
|
||||
template <typename Spec>
|
||||
Handle<TypeFeedbackMetadata> NewTypeFeedbackMetadata(Isolate* isolate,
|
||||
Spec* spec) {
|
||||
return TypeFeedbackMetadata::New(isolate, spec);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
Loading…
Reference in New Issue
Block a user