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

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

Issue 1909903003: [Interpreter] Use FastNewSloppyArguments when possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | src/interpreter/interpreter-assembler.h » ('j') | src/x64/code-stubs-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "src/compiler.h" 11 #include "src/compiler.h"
12 #include "src/factory.h" 12 #include "src/factory.h"
13 #include "src/interpreter/bytecode-generator.h" 13 #include "src/interpreter/bytecode-generator.h"
14 #include "src/interpreter/bytecodes.h" 14 #include "src/interpreter/bytecodes.h"
15 #include "src/interpreter/interpreter-assembler.h" 15 #include "src/interpreter/interpreter-assembler.h"
16 #include "src/interpreter/interpreter-intrinsics.h" 16 #include "src/interpreter/interpreter-intrinsics.h"
17 #include "src/log.h" 17 #include "src/log.h"
18 #include "src/zone.h" 18 #include "src/zone.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 namespace interpreter { 22 namespace interpreter {
23 23
24 using compiler::Node; 24 using compiler::Node;
25 typedef CodeStubAssembler::Label Label;
26 typedef CodeStubAssembler::Variable Variable;
25 27
26 #define __ assembler-> 28 #define __ assembler->
27 29
28 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { 30 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
29 memset(dispatch_table_, 0, sizeof(dispatch_table_)); 31 memset(dispatch_table_, 0, sizeof(dispatch_table_));
30 } 32 }
31 33
32 void Interpreter::Initialize() { 34 void Interpreter::Initialize() {
33 if (IsDispatchTableInitialized()) return; 35 if (IsDispatchTableInitialized()) return;
34 Zone zone(isolate_->allocator()); 36 Zone zone(isolate_->allocator());
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 __ SetAccumulator(result); 1456 __ SetAccumulator(result);
1455 __ Dispatch(); 1457 __ Dispatch();
1456 } 1458 }
1457 1459
1458 // CreateMappedArguments 1460 // CreateMappedArguments
1459 // 1461 //
1460 // Creates a new mapped arguments object. 1462 // Creates a new mapped arguments object.
1461 void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { 1463 void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) {
1462 Node* closure = __ LoadRegister(Register::function_closure()); 1464 Node* closure = __ LoadRegister(Register::function_closure());
1463 Node* context = __ GetContext(); 1465 Node* context = __ GetContext();
1464 Node* result = 1466
1465 __ CallRuntime(Runtime::kNewSloppyArguments_Generic, context, closure); 1467 Variable result(assembler, MachineRepresentation::kTagged);
1466 __ SetAccumulator(result); 1468 Label end(assembler), if_duplicate_parameters(assembler),
1469 if_not_duplicate_parameters(assembler);
1470
1471 // Check if function has duplicate parameters.
1472 // TODO(rmcilroy): Remove this check when FastNewSloppyArgumentsStub supports
1473 // duplicate parameters.
1474 Node* shared_info =
1475 __ LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset);
1476 Node* compiler_hints = __ LoadObjectField(
1477 shared_info, SharedFunctionInfo::kHasDuplicateParametersByteOffset,
1478 MachineType::Uint8());
1479 Node* duplicate_parameters_bit = __ Int32Constant(
1480 1 << SharedFunctionInfo::kHasDuplicateParametersBitWithinByte);
1481 Node* compare = __ Word32And(compiler_hints, duplicate_parameters_bit);
1482 __ BranchIf(compare, &if_duplicate_parameters, &if_not_duplicate_parameters);
1483
1484 __ Bind(&if_duplicate_parameters);
1485 {
1486 result.Bind(
1487 __ CallRuntime(Runtime::kNewSloppyArguments_Generic, context, closure));
1488 __ Goto(&end);
1489 }
1490
1491 __ Bind(&if_not_duplicate_parameters);
1492 {
1493 Callable callable = CodeFactory::FastNewSloppyArguments(isolate_);
1494 Node* target = __ HeapConstant(callable.code());
1495 result.Bind(__ CallStub(callable.descriptor(), target, context, closure));
1496 __ Goto(&end);
1497 }
1498 __ Bind(&end);
1499 __ SetAccumulator(result.value());
1467 __ Dispatch(); 1500 __ Dispatch();
1468 } 1501 }
1469 1502
1470 1503
1471 // CreateUnmappedArguments 1504 // CreateUnmappedArguments
1472 // 1505 //
1473 // Creates a new unmapped arguments object. 1506 // Creates a new unmapped arguments object.
1474 void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) { 1507 void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) {
1475 Callable callable = CodeFactory::FastNewStrictArguments(isolate_); 1508 Callable callable = CodeFactory::FastNewStrictArguments(isolate_);
1476 Node* target = __ HeapConstant(callable.code()); 1509 Node* target = __ HeapConstant(callable.code());
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 // Illegal 1714 // Illegal
1682 // 1715 //
1683 // An invalid bytecode aborting execution if dispatched. 1716 // An invalid bytecode aborting execution if dispatched.
1684 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { 1717 void Interpreter::DoIllegal(InterpreterAssembler* assembler) {
1685 __ Abort(kInvalidBytecode); 1718 __ Abort(kInvalidBytecode);
1686 } 1719 }
1687 1720
1688 } // namespace interpreter 1721 } // namespace interpreter
1689 } // namespace internal 1722 } // namespace internal
1690 } // namespace v8 1723 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/interpreter-assembler.h » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698