Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1922523002: [Interpreter] Use FastCloneShallowObjectStub in CreateObjectLiteral bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add todo Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 // if the object referenced by the accumulator is the hole constant. 1388 // if the object referenced by the accumulator is the hole constant.
1389 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) { 1389 void Interpreter::DoJumpIfNotHoleConstant(InterpreterAssembler* assembler) {
1390 Node* accumulator = __ GetAccumulator(); 1390 Node* accumulator = __ GetAccumulator();
1391 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value()); 1391 Node* the_hole_value = __ HeapConstant(isolate_->factory()->the_hole_value());
1392 Node* index = __ BytecodeOperandIdx(0); 1392 Node* index = __ BytecodeOperandIdx(0);
1393 Node* constant = __ LoadConstantPoolEntry(index); 1393 Node* constant = __ LoadConstantPoolEntry(index);
1394 Node* relative_jump = __ SmiUntag(constant); 1394 Node* relative_jump = __ SmiUntag(constant);
1395 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump); 1395 __ JumpIfWordNotEqual(accumulator, the_hole_value, relative_jump);
1396 } 1396 }
1397 1397
1398 void Interpreter::DoCreateLiteral(Runtime::FunctionId function_id,
1399 InterpreterAssembler* assembler) {
1400 Node* index = __ BytecodeOperandIdx(0);
1401 Node* constant_elements = __ LoadConstantPoolEntry(index);
1402 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1403 Node* literal_index = __ SmiTag(literal_index_raw);
1404 Node* flags_raw = __ BytecodeOperandFlag(2);
1405 Node* flags = __ SmiTag(flags_raw);
1406 Node* closure = __ LoadRegister(Register::function_closure());
1407 Node* context = __ GetContext();
1408 Node* result = __ CallRuntime(function_id, context, closure, literal_index,
1409 constant_elements, flags);
1410 __ SetAccumulator(result);
1411 __ Dispatch();
1412 }
1413
1414
1415 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags> 1398 // CreateRegExpLiteral <pattern_idx> <literal_idx> <flags>
1416 // 1399 //
1417 // Creates a regular expression literal for literal index <literal_idx> with 1400 // Creates a regular expression literal for literal index <literal_idx> with
1418 // <flags> and the pattern in <pattern_idx>. 1401 // <flags> and the pattern in <pattern_idx>.
1419 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) { 1402 void Interpreter::DoCreateRegExpLiteral(InterpreterAssembler* assembler) {
1420 Callable callable = CodeFactory::FastCloneRegExp(isolate_); 1403 Callable callable = CodeFactory::FastCloneRegExp(isolate_);
1421 Node* target = __ HeapConstant(callable.code()); 1404 Node* target = __ HeapConstant(callable.code());
1422 Node* index = __ BytecodeOperandIdx(0); 1405 Node* index = __ BytecodeOperandIdx(0);
1423 Node* pattern = __ LoadConstantPoolEntry(index); 1406 Node* pattern = __ LoadConstantPoolEntry(index);
1424 Node* literal_index_raw = __ BytecodeOperandIdx(1); 1407 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1425 Node* literal_index = __ SmiTag(literal_index_raw); 1408 Node* literal_index = __ SmiTag(literal_index_raw);
1426 Node* flags_raw = __ BytecodeOperandFlag(2); 1409 Node* flags_raw = __ BytecodeOperandFlag(2);
1427 Node* flags = __ SmiTag(flags_raw); 1410 Node* flags = __ SmiTag(flags_raw);
1428 Node* closure = __ LoadRegister(Register::function_closure()); 1411 Node* closure = __ LoadRegister(Register::function_closure());
1429 Node* context = __ GetContext(); 1412 Node* context = __ GetContext();
1430 Node* result = __ CallStub(callable.descriptor(), target, context, closure, 1413 Node* result = __ CallStub(callable.descriptor(), target, context, closure,
1431 literal_index, pattern, flags); 1414 literal_index, pattern, flags);
1432 __ SetAccumulator(result); 1415 __ SetAccumulator(result);
1433 __ Dispatch(); 1416 __ Dispatch();
1434 } 1417 }
1435 1418
1436 // CreateArrayLiteral <element_idx> <literal_idx> <flags> 1419 // CreateArrayLiteral <element_idx> <literal_idx> <flags>
1437 // 1420 //
1438 // Creates an array literal for literal index <literal_idx> with flags <flags> 1421 // Creates an array literal for literal index <literal_idx> with flags <flags>
1439 // and constant elements in <element_idx>. 1422 // and constant elements in <element_idx>.
1440 void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) { 1423 void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) {
1441 DoCreateLiteral(Runtime::kCreateArrayLiteral, assembler); 1424 Node* index = __ BytecodeOperandIdx(0);
1425 Node* constant_elements = __ LoadConstantPoolEntry(index);
1426 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1427 Node* literal_index = __ SmiTag(literal_index_raw);
1428 Node* flags_raw = __ BytecodeOperandFlag(2);
1429 Node* flags = __ SmiTag(flags_raw);
1430 Node* closure = __ LoadRegister(Register::function_closure());
1431 Node* context = __ GetContext();
1432 Node* result = __ CallRuntime(Runtime::kCreateArrayLiteral, context, closure,
1433 literal_index, constant_elements, flags);
1434 __ SetAccumulator(result);
1435 __ Dispatch();
1442 } 1436 }
1443 1437
1444 // CreateObjectLiteral <element_idx> <literal_idx> <flags> 1438 // CreateObjectLiteral <element_idx> <literal_idx> <flags>
1445 // 1439 //
1446 // Creates an object literal for literal index <literal_idx> with flags <flags> 1440 // Creates an object literal for literal index <literal_idx> with
1447 // and constant elements in <element_idx>. 1441 // CreateObjectLiteralFlags <flags> and constant elements in <element_idx>.
1448 void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) { 1442 void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) {
1449 DoCreateLiteral(Runtime::kCreateObjectLiteral, assembler); 1443 Node* literal_index_raw = __ BytecodeOperandIdx(1);
1444 Node* literal_index = __ SmiTag(literal_index_raw);
1445 Node* bytecode_flags = __ BytecodeOperandFlag(2);
1446 Node* closure = __ LoadRegister(Register::function_closure());
1447
1448 Variable result(assembler, MachineRepresentation::kTagged);
1449
1450 // Check if we can do a fast clone or have to call the runtime.
1451 Label end(assembler), if_fast_clone(assembler),
1452 if_not_fast_clone(assembler, Label::kDeferred);
1453 Node* fast_clone_properties_count =
1454 __ BitFieldDecode<CreateObjectLiteralFlags::FastClonePropertiesCountBits>(
1455 bytecode_flags);
1456 __ BranchIf(fast_clone_properties_count, &if_fast_clone, &if_not_fast_clone);
1457
1458 __ Bind(&if_fast_clone);
1459 {
1460 // If we can do a fast clone do the fast-path in FastCloneShallowObjectStub.
1461 Node* clone = FastCloneShallowObjectStub::GenerateFastPath(
1462 assembler, &if_not_fast_clone, closure, literal_index,
1463 fast_clone_properties_count);
1464 result.Bind(clone);
1465 __ Goto(&end);
1466 }
1467
1468 __ Bind(&if_not_fast_clone);
1469 {
1470 // If we can't do a fast clone, call into the runtime.
1471 Node* index = __ BytecodeOperandIdx(0);
1472 Node* constant_elements = __ LoadConstantPoolEntry(index);
1473 Node* context = __ GetContext();
1474
1475 STATIC_ASSERT(CreateObjectLiteralFlags::FlagsBits::kShift == 0);
1476 Node* flags_raw = __ Word32And(
1477 bytecode_flags,
1478 __ Int32Constant(CreateObjectLiteralFlags::FlagsBits::kMask));
1479 Node* flags = __ SmiTag(flags_raw);
1480
1481 result.Bind(__ CallRuntime(Runtime::kCreateObjectLiteral, context, closure,
1482 literal_index, constant_elements, flags));
1483 __ Goto(&end);
1484 }
1485
1486 __ Bind(&end);
1487 __ SetAccumulator(result.value());
1488 __ Dispatch();
1450 } 1489 }
1451 1490
1452 // CreateClosure <index> <tenured> 1491 // CreateClosure <index> <tenured>
1453 // 1492 //
1454 // Creates a new closure for SharedFunctionInfo at position |index| in the 1493 // Creates a new closure for SharedFunctionInfo at position |index| in the
1455 // constant pool and with the PretenureFlag <tenured>. 1494 // constant pool and with the PretenureFlag <tenured>.
1456 void Interpreter::DoCreateClosure(InterpreterAssembler* assembler) { 1495 void Interpreter::DoCreateClosure(InterpreterAssembler* assembler) {
1457 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of 1496 // TODO(rmcilroy): Possibly call FastNewClosureStub when possible instead of
1458 // calling into the runtime. 1497 // calling into the runtime.
1459 Node* index = __ BytecodeOperandIdx(0); 1498 Node* index = __ BytecodeOperandIdx(0);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 1806 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
1768 __ SmiTag(new_state)); 1807 __ SmiTag(new_state));
1769 __ SetAccumulator(old_state); 1808 __ SetAccumulator(old_state);
1770 1809
1771 __ Dispatch(); 1810 __ Dispatch();
1772 } 1811 }
1773 1812
1774 } // namespace interpreter 1813 } // namespace interpreter
1775 } // namespace internal 1814 } // namespace internal
1776 } // namespace v8 1815 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698