Commit 67c99a99 authored by mythria's avatar mythria Committed by Commit bot

[Interpreter] Adds wide variant of CreateLiterals. Adds CreateLiterals to BytecodeGraphBuilder.

Adds implementation and tests for CreateObjectLiteral, CreateArrayLiteral and CreateRegExpLiteral
to bytecode graph builder. Also changes these bytecodes to expect three operands instead of using
accumulator to pass one of the operands. This is done to avoid looking into the earlier nodes to
fetch operands in the bytecode graph builder. Also adds support for wide variant of these
bytecodes to bytecode generator and bytecode graph builder.

BUG=v8:4280
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#32710}
parent 82fd0047
......@@ -702,21 +702,82 @@ void BytecodeGraphBuilder::VisitCreateUnmappedArguments(
}
void BytecodeGraphBuilder::BuildCreateLiteral(const Operator* op) {
Node* literal = NewNode(op, GetFunctionClosure());
AddEmptyFrameStateInputs(literal);
environment()->BindAccumulator(literal);
}
void BytecodeGraphBuilder::BuildCreateRegExpLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
Handle<String> constant_pattern =
Handle<String>::cast(iterator.GetConstantForIndexOperand(0));
int literal_index = iterator.GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralRegExp(
constant_pattern, literal_flags, literal_index);
BuildCreateLiteral(op);
}
void BytecodeGraphBuilder::VisitCreateRegExpLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
BuildCreateRegExpLiteral(iterator);
}
void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateRegExpLiteral(iterator);
}
void BytecodeGraphBuilder::BuildCreateArrayLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
Handle<FixedArray> constant_elements =
Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0));
int literal_index = iterator.GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralArray(
constant_elements, literal_flags, literal_index);
BuildCreateLiteral(op);
}
void BytecodeGraphBuilder::VisitCreateArrayLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
BuildCreateArrayLiteral(iterator);
}
void BytecodeGraphBuilder::VisitCreateArrayLiteralWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateArrayLiteral(iterator);
}
void BytecodeGraphBuilder::BuildCreateObjectLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
Handle<FixedArray> constant_properties =
Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0));
int literal_index = iterator.GetIndexOperand(1);
int literal_flags = iterator.GetImmediateOperand(2);
const Operator* op = javascript()->CreateLiteralObject(
constant_properties, literal_flags, literal_index);
BuildCreateLiteral(op);
}
void BytecodeGraphBuilder::VisitCreateObjectLiteral(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
BuildCreateObjectLiteral(iterator);
}
void BytecodeGraphBuilder::VisitCreateObjectLiteralWide(
const interpreter::BytecodeArrayIterator& iterator) {
BuildCreateObjectLiteral(iterator);
}
......
......@@ -107,6 +107,13 @@ class BytecodeGraphBuilder {
interpreter::Register first_arg,
size_t arity);
void BuildCreateLiteral(const Operator* op);
void BuildCreateRegExpLiteral(
const interpreter::BytecodeArrayIterator& iterator);
void BuildCreateArrayLiteral(
const interpreter::BytecodeArrayIterator& iterator);
void BuildCreateObjectLiteral(
const interpreter::BytecodeArrayIterator& iterator);
void BuildLoadGlobal(const interpreter::BytecodeArrayIterator& iterator,
TypeofMode typeof_mode);
void BuildStoreGlobal(const interpreter::BytecodeArrayIterator& iterator);
......
......@@ -537,11 +537,17 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArguments(
BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral(
int literal_index, int flags) {
Handle<String> pattern, int literal_index, int flags) {
DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits.
if (FitsInIdx8Operand(literal_index)) {
Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(literal_index),
static_cast<uint8_t>(flags));
size_t pattern_entry = GetConstantPoolEntry(pattern);
if (FitsInIdx8Operand(literal_index) && FitsInIdx8Operand(pattern_entry)) {
Output(Bytecode::kCreateRegExpLiteral, static_cast<uint8_t>(pattern_entry),
static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags));
} else if (FitsInIdx16Operand(literal_index) &&
FitsInIdx16Operand(pattern_entry)) {
Output(Bytecode::kCreateRegExpLiteralWide,
static_cast<uint16_t>(pattern_entry),
static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags));
} else {
UNIMPLEMENTED();
}
......@@ -550,11 +556,19 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateRegExpLiteral(
BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArrayLiteral(
int literal_index, int flags) {
Handle<FixedArray> constant_elements, int literal_index, int flags) {
DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits.
if (FitsInIdx8Operand(literal_index)) {
Output(Bytecode::kCreateArrayLiteral, static_cast<uint8_t>(literal_index),
static_cast<uint8_t>(flags));
size_t constant_elements_entry = GetConstantPoolEntry(constant_elements);
if (FitsInIdx8Operand(literal_index) &&
FitsInIdx8Operand(constant_elements_entry)) {
Output(Bytecode::kCreateArrayLiteral,
static_cast<uint8_t>(constant_elements_entry),
static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags));
} else if (FitsInIdx16Operand(literal_index) &&
FitsInIdx16Operand(constant_elements_entry)) {
Output(Bytecode::kCreateArrayLiteralWide,
static_cast<uint16_t>(constant_elements_entry),
static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags));
} else {
UNIMPLEMENTED();
}
......@@ -563,11 +577,19 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArrayLiteral(
BytecodeArrayBuilder& BytecodeArrayBuilder::CreateObjectLiteral(
int literal_index, int flags) {
Handle<FixedArray> constant_properties, int literal_index, int flags) {
DCHECK(FitsInImm8Operand(flags)); // Flags should fit in 8 bits.
if (FitsInIdx8Operand(literal_index)) {
Output(Bytecode::kCreateObjectLiteral, static_cast<uint8_t>(literal_index),
static_cast<uint8_t>(flags));
size_t constant_properties_entry = GetConstantPoolEntry(constant_properties);
if (FitsInIdx8Operand(literal_index) &&
FitsInIdx8Operand(constant_properties_entry)) {
Output(Bytecode::kCreateObjectLiteral,
static_cast<uint8_t>(constant_properties_entry),
static_cast<uint8_t>(literal_index), static_cast<uint8_t>(flags));
} else if (FitsInIdx16Operand(literal_index) &&
FitsInIdx16Operand(constant_properties_entry)) {
Output(Bytecode::kCreateObjectLiteralWide,
static_cast<uint16_t>(constant_properties_entry),
static_cast<uint16_t>(literal_index), static_cast<uint8_t>(flags));
} else {
UNIMPLEMENTED();
}
......
......@@ -125,9 +125,12 @@ class BytecodeArrayBuilder {
BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type);
// Literals creation. Constant elements should be in the accumulator.
BytecodeArrayBuilder& CreateRegExpLiteral(int literal_index, int flags);
BytecodeArrayBuilder& CreateArrayLiteral(int literal_index, int flags);
BytecodeArrayBuilder& CreateObjectLiteral(int literal_index, int flags);
BytecodeArrayBuilder& CreateRegExpLiteral(Handle<String> pattern,
int literal_index, int flags);
BytecodeArrayBuilder& CreateArrayLiteral(Handle<FixedArray> constant_elements,
int literal_index, int flags);
BytecodeArrayBuilder& CreateObjectLiteral(
Handle<FixedArray> constant_properties, int literal_index, int flags);
// Push the context in accumulator as the new context, and store in register
// |context|.
......
......@@ -1040,18 +1040,17 @@ void BytecodeGenerator::VisitLiteral(Literal* expr) {
void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
// Materialize a regular expression literal.
TemporaryRegisterScope temporary_register_scope(builder());
builder()
->LoadLiteral(expr->pattern())
.CreateRegExpLiteral(expr->literal_index(), expr->flags());
builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(),
expr->flags());
execution_result()->SetResultInAccumulator();
}
void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
// Deep-copy the literal boilerplate.
builder()
->LoadLiteral(expr->constant_properties())
.CreateObjectLiteral(expr->literal_index(), expr->ComputeFlags(true));
builder()->CreateObjectLiteral(expr->constant_properties(),
expr->literal_index(),
expr->ComputeFlags(true));
TemporaryRegisterScope temporary_register_scope(builder());
Register literal;
......@@ -1243,9 +1242,9 @@ void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
// Deep-copy the literal boilerplate.
builder()
->LoadLiteral(expr->constant_elements())
.CreateArrayLiteral(expr->literal_index(), expr->ComputeFlags(true));
builder()->CreateArrayLiteral(expr->constant_elements(),
expr->literal_index(),
expr->ComputeFlags(true));
TemporaryRegisterScope temporary_register_scope(builder());
Register index, literal;
......
......@@ -155,9 +155,18 @@ namespace interpreter {
V(ToObject, OperandType::kNone) \
\
/* Literals */ \
V(CreateRegExpLiteral, OperandType::kIdx8, OperandType::kImm8) \
V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kImm8) \
V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kImm8) \
V(CreateRegExpLiteral, OperandType::kIdx8, OperandType::kIdx8, \
OperandType::kImm8) \
V(CreateArrayLiteral, OperandType::kIdx8, OperandType::kIdx8, \
OperandType::kImm8) \
V(CreateObjectLiteral, OperandType::kIdx8, OperandType::kIdx8, \
OperandType::kImm8) \
V(CreateRegExpLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \
OperandType::kImm8) \
V(CreateArrayLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \
OperandType::kImm8) \
V(CreateObjectLiteralWide, OperandType::kIdx16, OperandType::kIdx16, \
OperandType::kImm8) \
\
/* Closure allocation */ \
V(CreateClosure, OperandType::kIdx8, OperandType::kImm8) \
......
......@@ -1305,10 +1305,11 @@ void Interpreter::DoJumpIfUndefinedConstant(
void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id,
compiler::InterpreterAssembler* assembler) {
Node* constant_elements = __ GetAccumulator();
Node* literal_index_raw = __ BytecodeOperandIdx(0);
Node* index = __ BytecodeOperandIdx(0);
Node* constant_elements = __ LoadConstantPoolEntry(index);
Node* literal_index_raw = __ BytecodeOperandIdx(1);
Node* literal_index = __ SmiTag(literal_index_raw);
Node* flags_raw = __ BytecodeOperandImm(1);
Node* flags_raw = __ BytecodeOperandImm(2);
Node* flags = __ SmiTag(flags_raw);
Node* closure = __ LoadRegister(Register::function_closure());
Node* result = __ CallRuntime(function_id, closure, literal_index,
......@@ -1318,36 +1319,66 @@ void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id,
}
// CreateRegExpLiteral <idx> <flags>
// CreateRegExpLiteral <pattern_idx> <literal_idx> <flags>
//
// Creates a regular expression literal for literal index <idx> with <flags> and
// the pattern in the accumulator.
// Creates a regular expression literal for literal index <literal_idx> with
// <flags> and the pattern in <pattern_idx>.
void Interpreter::DoCreateRegExpLiteral(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateRegExpLiteral, assembler);
}
// CreateArrayLiteral <idx> <flags>
// CreateRegExpLiteralWide <pattern_idx> <literal_idx> <flags>
//
// Creates a regular expression literal for literal index <literal_idx> with
// <flags> and the pattern in <pattern_idx>.
void Interpreter::DoCreateRegExpLiteralWide(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateRegExpLiteral, assembler);
}
// CreateArrayLiteral <element_idx> <literal_idx> <flags>
//
// Creates an array literal for literal index <idx> with flags <flags> and
// constant elements in the accumulator.
// Creates an array literal for literal index <literal_idx> with flags <flags>
// and constant elements in <element_idx>.
void Interpreter::DoCreateArrayLiteral(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateArrayLiteral, assembler);
}
// CreateObjectLiteral <idx> <flags>
// CreateArrayLiteralWide <element_idx> <literal_idx> <flags>
//
// Creates an object literal for literal index <idx> with flags <flags> and
// constant elements in the accumulator.
// Creates an array literal for literal index <literal_idx> with flags <flags>
// and constant elements in <element_idx>.
void Interpreter::DoCreateArrayLiteralWide(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateArrayLiteral, assembler);
}
// CreateObjectLiteral <element_idx> <literal_idx> <flags>
//
// Creates an object literal for literal index <literal_idx> with flags <flags>
// and constant elements in <element_idx>.
void Interpreter::DoCreateObjectLiteral(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateObjectLiteral, assembler);
}
// CreateObjectLiteralWide <element_idx> <literal_idx> <flags>
//
// Creates an object literal for literal index <literal_idx> with flags <flags>
// and constant elements in <element_idx>.
void Interpreter::DoCreateObjectLiteralWide(
compiler::InterpreterAssembler* assembler) {
DoCreateLiteral(Runtime::kCreateObjectLiteral, assembler);
}
// CreateClosure <index> <tenured>
//
// Creates a new closure for SharedFunctionInfo at position |index| in the
......
......@@ -1183,6 +1183,150 @@ TEST(BytecodeGraphBuilderLoadContext) {
}
}
TEST(BytecodeGraphBuilderRegExpLiterals) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Zone* zone = scope.main_zone();
Factory* factory = isolate->factory();
ExpectedSnippet<0> snippets[] = {
{"return /abd/.exec('cccabbdd');", {factory->null_value()}},
{"return /ab+d/.exec('cccabbdd')[0];",
{factory->NewStringFromStaticChars("abbd")}},
{"var a = 3.1414;"
REPEAT_256(SPACE, "a = 3.1414;")
"return /ab+d/.exec('cccabbdd')[0];",
{factory->NewStringFromStaticChars("abbd")}},
{"return /ab+d/.exec('cccabbdd')[1];", {factory->undefined_value()}},
{"return /AbC/i.exec('ssaBC')[0];",
{factory->NewStringFromStaticChars("aBC")}},
{"return 'ssaBC'.match(/AbC/i)[0];",
{factory->NewStringFromStaticChars("aBC")}},
{"return 'ssaBCtAbC'.match(/(AbC)/gi)[1];",
{factory->NewStringFromStaticChars("AbC")}},
};
size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
for (size_t i = 0; i < num_snippets; i++) {
ScopedVector<char> script(4096);
SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
snippets[i].code_snippet, kFunctionName);
BytecodeGraphTester tester(isolate, zone, script.start());
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*snippets[i].return_value()));
}
}
TEST(BytecodeGraphBuilderArrayLiterals) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Zone* zone = scope.main_zone();
Factory* factory = isolate->factory();
ExpectedSnippet<0> snippets[] = {
{"return [][0];", {factory->undefined_value()}},
{"return [1, 3, 2][1];", {factory->NewNumberFromInt(3)}},
{"var a;" REPEAT_256(SPACE, "a = 9.87;") "return [1, 3, 2][1];",
{factory->NewNumberFromInt(3)}},
{"return ['a', 'b', 'c'][2];", {factory->NewStringFromStaticChars("c")}},
{"var a = 100; return [a, a++, a + 2, a + 3][2];",
{factory->NewNumberFromInt(103)}},
{"var a = 100; return [a, ++a, a + 2, a + 3][1];",
{factory->NewNumberFromInt(101)}},
{"var a = 9.2;"
REPEAT_256(SPACE, "a = 9.34;")
"return [a, ++a, a + 2, a + 3][2];",
{factory->NewHeapNumber(12.34)}},
{"return [[1, 2, 3], ['a', 'b', 'c']][1][0];",
{factory->NewStringFromStaticChars("a")}},
{"var t = 't'; return [[t, t + 'est'], [1 + t]][0][1];",
{factory->NewStringFromStaticChars("test")}},
{"var t = 't'; return [[t, t + 'est'], [1 + t]][1][0];",
{factory->NewStringFromStaticChars("1t")}}};
size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
for (size_t i = 0; i < num_snippets; i++) {
ScopedVector<char> script(4096);
SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
snippets[i].code_snippet, kFunctionName);
BytecodeGraphTester tester(isolate, zone, script.start());
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*snippets[i].return_value()));
}
}
TEST(BytecodeGraphBuilderObjectLiterals) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
Zone* zone = scope.main_zone();
Factory* factory = isolate->factory();
ExpectedSnippet<0> snippets[] = {
{"return { }.name;", {factory->undefined_value()}},
{"return { name: 'string', val: 9.2 }.name;",
{factory->NewStringFromStaticChars("string")}},
{"var a;\n"
REPEAT_256(SPACE, "a = 1.23;\n")
"return { name: 'string', val: 9.2 }.name;",
{factory->NewStringFromStaticChars("string")}},
{"return { name: 'string', val: 9.2 }['name'];",
{factory->NewStringFromStaticChars("string")}},
{"var a = 15; return { name: 'string', val: a }.val;",
{factory->NewNumberFromInt(15)}},
{"var a;"
REPEAT_256(SPACE, "a = 1.23;")
"return { name: 'string', val: a }.val;",
{factory->NewHeapNumber(1.23)}},
{"var a = 15; var b = 'val'; return { name: 'string', val: a }[b];",
{factory->NewNumberFromInt(15)}},
{"var a = 5; return { val: a, val: a + 1 }.val;",
{factory->NewNumberFromInt(6)}},
{"return { func: function() { return 'test' } }.func();",
{factory->NewStringFromStaticChars("test")}},
{"return { func(a) { return a + 'st'; } }.func('te');",
{factory->NewStringFromStaticChars("test")}},
{"return { get a() { return 22; } }.a;", {factory->NewNumberFromInt(22)}},
{"var a = { get b() { return this.x + 't'; },\n"
" set b(val) { this.x = val + 's' } };\n"
"a.b = 'te';\n"
"return a.b;",
{factory->NewStringFromStaticChars("test")}},
{"var a = 123; return { 1: a }[1];", {factory->NewNumberFromInt(123)}},
{"return Object.getPrototypeOf({ __proto__: null });",
{factory->null_value()}},
{"var a = 'test'; return { [a]: 1 }.test;",
{factory->NewNumberFromInt(1)}},
{"var a = 'test'; return { b: a, [a]: a + 'ing' }['test']",
{factory->NewStringFromStaticChars("testing")}},
{"var a = 'proto_str';\n"
"var b = { [a]: 1, __proto__: { var : a } };\n"
"return Object.getPrototypeOf(b).var",
{factory->NewStringFromStaticChars("proto_str")}},
{"var n = 'name';\n"
"return { [n]: 'val', get a() { return 987 } }['a'];",
{factory->NewNumberFromInt(987)}},
};
size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
for (size_t i = 0; i < num_snippets; i++) {
ScopedVector<char> script(4096);
SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
snippets[i].code_snippet, kFunctionName);
BytecodeGraphTester tester(isolate, zone, script.start());
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();
CHECK(return_value->SameValue(*snippets[i].return_value()));
}
}
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -1599,12 +1599,11 @@ TEST(CallRuntime) {
"function f() { return %spread_iterable([1]) }\nf()",
2 * kPointerSize,
1,
16,
15,
{
B(LdaUndefined), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(3), //
B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
B(Star), R(1), //
B(CallJSRuntime), U16(Context::SPREAD_ITERABLE_INDEX), R(0), //
U8(1), //
......@@ -2602,13 +2601,12 @@ TEST(Delete) {
{"var a = {x:13, y:14}; return delete a.x;",
1 * kPointerSize,
1,
12,
11,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(DeletePropertySloppy), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(DeletePropertySloppy), R(0), //
B(Return)
},
2,
......@@ -2617,13 +2615,12 @@ TEST(Delete) {
{"'use strict'; var a = {x:13, y:14}; return delete a.x;",
1 * kPointerSize,
1,
12,
11,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(DeletePropertyStrict), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(DeletePropertyStrict), R(0), //
B(Return)
},
2,
......@@ -2632,13 +2629,12 @@ TEST(Delete) {
{"var a = {1:13, 2:14}; return delete a[2];",
1 * kPointerSize,
1,
12,
11,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaSmi8), U8(2), //
B(DeletePropertySloppy), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaSmi8), U8(2), //
B(DeletePropertySloppy), R(0), //
B(Return)
},
1,
......@@ -2660,19 +2656,18 @@ TEST(Delete) {
"return delete a[1];",
2 * kPointerSize,
1,
28,
27,
{
B(CallRuntime), U16(Runtime::kNewFunctionContext), //
R(closure), U8(1), //
B(PushContext), R(0), //
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(StaContextSlot), R(0), U8(first_context_slot), //
B(CreateClosure), U8(1), U8(0), //
B(LdaContextSlot), R(0), U8(first_context_slot), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(DeletePropertyStrict), R(1), //
B(CallRuntime), U16(Runtime::kNewFunctionContext), //
R(closure), U8(1), //
B(PushContext), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(StaContextSlot), R(0), U8(first_context_slot), //
B(CreateClosure), U8(1), U8(0), //
B(LdaContextSlot), R(0), U8(first_context_slot), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(DeletePropertyStrict), R(1), //
B(Return)
},
2,
......@@ -2850,32 +2845,29 @@ TEST(RegExpLiterals) {
{"return /ab+d/;",
0 * kPointerSize,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateRegExpLiteral), U8(0), U8(0), //
B(Return), //
B(CreateRegExpLiteral), U8(0), U8(0), U8(0), //
B(Return), //
},
1,
{"ab+d"}},
{"return /(\\w+)\\s(\\w+)/i;",
0 * kPointerSize,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateRegExpLiteral), U8(0), U8(i_flags), //
B(Return), //
B(CreateRegExpLiteral), U8(0), U8(0), U8(i_flags), //
B(Return), //
},
1,
{"(\\w+)\\s(\\w+)"}},
{"return /ab+d/.exec('abdd');",
3 * kPointerSize,
1,
23,
22,
{
B(LdaConstant), U8(0), //
B(CreateRegExpLiteral), U8(0), U8(0), //
B(CreateRegExpLiteral), U8(0), U8(0), U8(0), //
B(Star), R(1), //
B(LoadICSloppy), R(1), U8(1), U8(vector->GetIndex(slot2)), //
B(Star), R(0), //
......@@ -2896,6 +2888,38 @@ TEST(RegExpLiterals) {
}
TEST(RegExpLiteralsWide) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
int wide_idx = 0;
ExpectedSnippet<InstanceType, 257> snippets[] = {
{"var a;" REPEAT_256(SPACE, "a = 1.23;") "return /ab+d/;",
1 * kPointerSize,
1,
1031,
{
REPEAT_256(COMMA, //
B(LdaConstant), U8(wide_idx++), //
B(Star), R(0)), //
B(CreateRegExpLiteralWide), U16(256), U16(0), U8(0), //
B(Return) //
},
257,
{REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
CheckBytecodeArrayEqual(snippets[i], bytecode_array);
}
}
TEST(ArrayLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
......@@ -2916,23 +2940,21 @@ TEST(ArrayLiterals) {
{"return [ 1, 2 ];",
0,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(simple_flags), //
B(Return) //
B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return [ a, a + 1 ];",
3 * kPointerSize,
1,
35,
34,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(3), //
B(CreateArrayLiteral), U8(0), U8(0), U8(3), //
B(Star), R(2), //
B(LdaZero), //
B(Star), R(1), //
......@@ -2951,28 +2973,25 @@ TEST(ArrayLiterals) {
{"return [ [ 1, 2 ], [ 3 ] ];",
0,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), //
B(Return) //
B(CreateArrayLiteral), U8(0), U8(2), U8(deep_elements_flags), //
B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];",
5 * kPointerSize,
1,
67,
64,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(2), U8(deep_elements_flags), //
B(CreateArrayLiteral), U8(0), U8(2), U8(deep_elements_flags), //
B(Star), R(2), //
B(LdaZero), //
B(Star), R(1), //
B(LdaConstant), U8(1), //
B(CreateArrayLiteral), U8(0), U8(simple_flags), //
B(CreateArrayLiteral), U8(1), U8(0), U8(simple_flags), //
B(Star), R(4), //
B(LdaZero), //
B(Star), R(3), //
......@@ -2982,8 +3001,7 @@ TEST(ArrayLiterals) {
B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), //
B(LdaSmi8), U8(1), //
B(Star), R(1), //
B(LdaConstant), U8(2), //
B(CreateArrayLiteral), U8(1), U8(simple_flags), //
B(CreateArrayLiteral), U8(2), U8(1), U8(simple_flags), //
B(Star), R(4), //
B(LdaZero), //
B(Star), R(3), //
......@@ -3008,6 +3026,40 @@ TEST(ArrayLiterals) {
}
TEST(ArrayLiteralsWide) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
int wide_idx = 0;
int simple_flags =
ArrayLiteral::kDisableMementos | ArrayLiteral::kShallowElements;
ExpectedSnippet<InstanceType, 257> snippets[] = {
{"var a;" REPEAT_256(SPACE, "a = 1.23;") "return [ 1 , 2 ];",
1 * kPointerSize,
1,
1031,
{
REPEAT_256(COMMA, //
B(LdaConstant), U8(wide_idx++), //
B(Star), R(0)), //
B(CreateArrayLiteralWide), U16(256), U16(0), U8(simple_flags), //
B(Return) //
},
257,
{REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
InstanceType::FIXED_ARRAY_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
CheckBytecodeArrayEqual(snippets[i], bytecode_array);
}
}
TEST(ObjectLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
......@@ -3028,39 +3080,36 @@ TEST(ObjectLiterals) {
{"return { };",
0,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(simple_flags), //
B(Return) //
B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), //
B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"return { name: 'string', val: 9.2 };",
0,
1,
6,
5,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Return) //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return { name: 'string', val: a };",
2 * kPointerSize,
1,
20,
19,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(1), //
B(Return), //
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(1), //
B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3068,18 +3117,17 @@ TEST(ObjectLiterals) {
{"var a = 1; return { val: a, val: a + 1 };",
2 * kPointerSize,
1,
22,
21,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(Add), R(0), //
B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(1), //
B(Return), //
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(Add), R(0), //
B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(1), //
B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3087,15 +3135,14 @@ TEST(ObjectLiterals) {
{"return { func: function() { } };",
1 * kPointerSize,
1,
17,
16,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(CreateClosure), U8(2), U8(0), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(0), //
B(Return), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(CreateClosure), U8(2), U8(0), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(0), //
B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3104,15 +3151,14 @@ TEST(ObjectLiterals) {
{"return { func(a) { return a; } };",
1 * kPointerSize,
1,
17,
16,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(CreateClosure), U8(2), U8(0), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(0), //
B(Return), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(CreateClosure), U8(2), U8(0), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(0), //
B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3121,10 +3167,9 @@ TEST(ObjectLiterals) {
{"return { get a() { return 2; } };",
5 * kPointerSize,
1,
30,
29,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(Star), R(1), //
......@@ -3146,10 +3191,9 @@ TEST(ObjectLiterals) {
{"return { get a() { return this.x; }, set a(val) { this.x = val } };",
5 * kPointerSize,
1,
32,
31,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(Star), R(1), //
......@@ -3172,10 +3216,9 @@ TEST(ObjectLiterals) {
{"return { set b(val) { this.y = val } };",
5 * kPointerSize,
1,
30,
29,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(Star), R(1), //
......@@ -3197,32 +3240,30 @@ TEST(ObjectLiterals) {
{"var a = 1; return { 1: a };",
5 * kPointerSize,
1,
30,
29,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(Star), R(2), //
B(Ldar), R(0), //
B(Star), R(3), //
B(LdaZero), //
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), //
B(Ldar), R(1), //
B(Return), //
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(LdaSmi8), U8(1), //
B(Star), R(2), //
B(Ldar), R(0), //
B(Star), R(3), //
B(LdaZero), //
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), //
B(Ldar), R(1), //
B(Return), //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"return { __proto__: null }",
2 * kPointerSize,
1,
18,
17,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(simple_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(simple_flags), //
B(Star), R(0), //
B(LdaNull), B(Star), R(1), //
B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), //
......@@ -3234,12 +3275,11 @@ TEST(ObjectLiterals) {
{"var a = 'test'; return { [a]: 1 }",
5 * kPointerSize,
1,
31,
30,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(simple_flags), //
B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(ToName), //
......@@ -3259,12 +3299,11 @@ TEST(ObjectLiterals) {
{"var a = 'test'; return { val: a, [a]: 1 }",
5 * kPointerSize,
1,
37,
36,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(CreateObjectLiteral), U8(1), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), //
......@@ -3287,12 +3326,11 @@ TEST(ObjectLiterals) {
{"var a = 'test'; return { [a]: 1, __proto__: {} }",
5 * kPointerSize,
1,
43,
41,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(1), U8(simple_flags), //
B(CreateObjectLiteral), U8(1), U8(1), U8(simple_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(ToName), //
......@@ -3303,8 +3341,7 @@ TEST(ObjectLiterals) {
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
U8(4), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(13), //
B(CreateObjectLiteral), U8(1), U8(0), U8(13), //
B(Star), R(2), //
B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), //
B(Ldar), R(1), //
......@@ -3316,12 +3353,11 @@ TEST(ObjectLiterals) {
{"var n = 'name'; return { [n]: 'val', get a() { }, set a(b) {} };",
5 * kPointerSize,
1,
65,
64,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(simple_flags), //
B(CreateObjectLiteral), U8(1), U8(0), U8(simple_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(ToName), //
......@@ -3368,6 +3404,42 @@ TEST(ObjectLiterals) {
}
TEST(ObjectLiteralsWide) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
int deep_elements_flags =
ObjectLiteral::kFastElements | ObjectLiteral::kDisableMementos;
int wide_idx = 0;
ExpectedSnippet<InstanceType, 257> snippets[] = {
{"var a;" REPEAT_256(SPACE,
"a = 1.23;") "return { name: 'string', val: 9.2 };",
1 * kPointerSize,
1,
1031,
{
REPEAT_256(COMMA, //
B(LdaConstant), U8(wide_idx++), //
B(Star), R(0)), //
B(CreateObjectLiteralWide), U16(256), U16(0), //
U8(deep_elements_flags), //
B(Return) //
},
257,
{REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
InstanceType::FIXED_ARRAY_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
CheckBytecodeArrayEqual(snippets[i], bytecode_array);
}
}
TEST(TopLevelObjectLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
......@@ -3379,7 +3451,7 @@ TEST(TopLevelObjectLiterals) {
{"var a = { func: function() { } };",
5 * kPointerSize,
1,
49,
48,
{
B(LdaConstant), U8(0), //
B(Star), R(1), //
......@@ -3390,8 +3462,7 @@ TEST(TopLevelObjectLiterals) {
B(Star), R(1), //
B(LdaZero), //
B(Star), R(2), //
B(LdaConstant), U8(2), //
B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
B(CreateObjectLiteral), U8(2), U8(0), U8(has_function_flags), //
B(Star), R(4), //
B(CreateClosure), U8(4), U8(1), //
B(StoreICSloppy), R(4), U8(3), U8(3), //
......@@ -3958,18 +4029,17 @@ TEST(CountOperators) {
{"var a = { val: 1 }; return a.val++;",
2 * kPointerSize,
1,
22,
21,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(ToNumber), //
B(Star), R(1), //
B(Inc), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(Ldar), R(1), //
B(Return), //
B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(ToNumber), //
B(Star), R(1), //
B(Inc), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(Ldar), R(1), //
B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3977,16 +4047,15 @@ TEST(CountOperators) {
{"var a = { val: 1 }; return --a.val;",
1 * kPointerSize,
1,
18,
17,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(ToNumber), //
B(Dec), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(Return), //
B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(ToNumber), //
B(Dec), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -3994,12 +4063,11 @@ TEST(CountOperators) {
{"var name = 'var'; var a = { val: 1 }; return a[name]--;",
4 * kPointerSize,
1,
29,
28,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(CreateObjectLiteral), U8(1), U8(0), U8(object_literal_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(Star), R(2), //
......@@ -4017,12 +4085,11 @@ TEST(CountOperators) {
{"var name = 'var'; var a = { val: 1 }; return ++a[name];",
3 * kPointerSize,
1,
25,
24,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(CreateObjectLiteral), U8(1), U8(0), U8(object_literal_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(Star), R(2), //
......@@ -4080,12 +4147,11 @@ TEST(CountOperators) {
{"var idx = 1; var a = [1, 2]; return a[idx++] = 2;",
3 * kPointerSize,
1,
26,
25,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(array_literal_flags), //
B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), //
B(Star), R(1), //
B(Ldar), R(0), //
B(ToNumber), //
......@@ -4236,18 +4302,17 @@ TEST(CompoundExpressions) {
{"var a = { val: 2 }; a.name *= 2;",
2 * kPointerSize,
1,
23,
22,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Star), R(1), //
B(LdaSmi8), U8(2), //
B(Mul), R(1), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(LdaUndefined), //
B(Return), //
B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LoadICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
B(Star), R(1), //
B(LdaSmi8), U8(2), //
B(Mul), R(1), //
B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot2)), //
B(LdaUndefined), //
B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
......@@ -4255,10 +4320,9 @@ TEST(CompoundExpressions) {
{"var a = { 1: 2 }; a[1] ^= 2;",
3 * kPointerSize,
1,
26,
25,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(object_literal_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
B(Star), R(0), //
B(LdaSmi8), U8(1), //
B(Star), R(1), //
......@@ -4552,12 +4616,11 @@ TEST(ForIn) {
"for (var p in [1,2,3]) { x += p; }",
5 * kPointerSize,
1,
53,
52,
{
B(LdaZero), //
B(Star), R(1), //
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(simple_flags), //
B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
B(JumpIfUndefined), U8(43), //
B(JumpIfNull), U8(41), //
B(ToObject), //
......@@ -4591,13 +4654,11 @@ TEST(ForIn) {
"}",
4 * kPointerSize,
1,
83,
81,
{
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(CreateObjectLiteral), U8(0), U8(0), U8(deep_elements_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateArrayLiteral), U8(1), U8(simple_flags), //
B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
B(JumpIfUndefined), U8(69), //
B(JumpIfNull), U8(67), //
B(ToObject), //
......@@ -4639,13 +4700,11 @@ TEST(ForIn) {
"for (x[0] in [1,2,3]) { return x[3]; }",
5 * kPointerSize,
1,
66,
64,
{
B(LdaConstant), U8(0), //
B(CreateArrayLiteral), U8(0), U8(simple_flags), //
B(CreateArrayLiteral), U8(0), U8(0), U8(simple_flags), //
B(Star), R(0), //
B(LdaConstant), U8(1), //
B(CreateArrayLiteral), U8(1), U8(simple_flags), //
B(CreateArrayLiteral), U8(1), U8(1), U8(simple_flags), //
B(JumpIfUndefined), U8(52), //
B(JumpIfNull), U8(50), //
B(ToObject), //
......
......@@ -104,10 +104,10 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.CreateArguments(CreateArgumentsType::kMappedArguments)
.CreateArguments(CreateArgumentsType::kUnmappedArguments);
// Emit literal creation operations
builder.CreateRegExpLiteral(0, 0)
.CreateArrayLiteral(0, 0)
.CreateObjectLiteral(0, 0);
// Emit literal creation operations.
builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0)
.CreateArrayLiteral(factory->NewFixedArray(1), 0, 0)
.CreateObjectLiteral(factory->NewFixedArray(1), 0, 0);
// Call operations.
builder.Call(reg, reg, 0, 0)
......@@ -224,6 +224,12 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
false);
builder.CreateClosure(shared_info2, NOT_TENURED);
// Emit wide variant of literal creation operations.
builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("wide_literal"),
0, 0)
.CreateArrayLiteral(factory->NewFixedArray(2), 0, 0)
.CreateObjectLiteral(factory->NewFixedArray(2), 0, 0);
builder.Return();
// Generate BytecodeArray.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment