| OLD | NEW |
| 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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 __ SetAccumulator(result); | 1466 __ SetAccumulator(result); |
| 1465 __ Dispatch(); | 1467 __ Dispatch(); |
| 1466 } | 1468 } |
| 1467 | 1469 |
| 1468 // CreateMappedArguments | 1470 // CreateMappedArguments |
| 1469 // | 1471 // |
| 1470 // Creates a new mapped arguments object. | 1472 // Creates a new mapped arguments object. |
| 1471 void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { | 1473 void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { |
| 1472 Node* closure = __ LoadRegister(Register::function_closure()); | 1474 Node* closure = __ LoadRegister(Register::function_closure()); |
| 1473 Node* context = __ GetContext(); | 1475 Node* context = __ GetContext(); |
| 1474 Node* result = | 1476 |
| 1475 __ CallRuntime(Runtime::kNewSloppyArguments_Generic, context, closure); | 1477 Variable result(assembler, MachineRepresentation::kTagged); |
| 1476 __ SetAccumulator(result); | 1478 Label end(assembler), if_duplicate_parameters(assembler), |
| 1479 if_not_duplicate_parameters(assembler); |
| 1480 |
| 1481 // Check if function has duplicate parameters. |
| 1482 // TODO(rmcilroy): Remove this check when FastNewSloppyArgumentsStub supports |
| 1483 // duplicate parameters. |
| 1484 Node* shared_info = |
| 1485 __ LoadObjectField(closure, JSFunction::kSharedFunctionInfoOffset); |
| 1486 Node* compiler_hints = __ LoadObjectField( |
| 1487 shared_info, SharedFunctionInfo::kHasDuplicateParametersByteOffset, |
| 1488 MachineType::Uint8()); |
| 1489 Node* duplicate_parameters_bit = __ Int32Constant( |
| 1490 1 << SharedFunctionInfo::kHasDuplicateParametersBitWithinByte); |
| 1491 Node* compare = __ Word32And(compiler_hints, duplicate_parameters_bit); |
| 1492 __ BranchIf(compare, &if_duplicate_parameters, &if_not_duplicate_parameters); |
| 1493 |
| 1494 __ Bind(&if_duplicate_parameters); |
| 1495 { |
| 1496 result.Bind( |
| 1497 __ CallRuntime(Runtime::kNewSloppyArguments_Generic, context, closure)); |
| 1498 __ Goto(&end); |
| 1499 } |
| 1500 |
| 1501 __ Bind(&if_not_duplicate_parameters); |
| 1502 { |
| 1503 Callable callable = CodeFactory::FastNewSloppyArguments(isolate_); |
| 1504 Node* target = __ HeapConstant(callable.code()); |
| 1505 result.Bind(__ CallStub(callable.descriptor(), target, context, closure)); |
| 1506 __ Goto(&end); |
| 1507 } |
| 1508 __ Bind(&end); |
| 1509 __ SetAccumulator(result.value()); |
| 1477 __ Dispatch(); | 1510 __ Dispatch(); |
| 1478 } | 1511 } |
| 1479 | 1512 |
| 1480 | 1513 |
| 1481 // CreateUnmappedArguments | 1514 // CreateUnmappedArguments |
| 1482 // | 1515 // |
| 1483 // Creates a new unmapped arguments object. | 1516 // Creates a new unmapped arguments object. |
| 1484 void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) { | 1517 void Interpreter::DoCreateUnmappedArguments(InterpreterAssembler* assembler) { |
| 1485 Callable callable = CodeFactory::FastNewStrictArguments(isolate_); | 1518 Callable callable = CodeFactory::FastNewStrictArguments(isolate_); |
| 1486 Node* target = __ HeapConstant(callable.code()); | 1519 Node* target = __ HeapConstant(callable.code()); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 // Illegal | 1724 // Illegal |
| 1692 // | 1725 // |
| 1693 // An invalid bytecode aborting execution if dispatched. | 1726 // An invalid bytecode aborting execution if dispatched. |
| 1694 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { | 1727 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { |
| 1695 __ Abort(kInvalidBytecode); | 1728 __ Abort(kInvalidBytecode); |
| 1696 } | 1729 } |
| 1697 | 1730 |
| 1698 } // namespace interpreter | 1731 } // namespace interpreter |
| 1699 } // namespace internal | 1732 } // namespace internal |
| 1700 } // namespace v8 | 1733 } // namespace v8 |
| OLD | NEW |