| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/interpreter/bytecode-array-builder.h" | 7 #include "src/interpreter/bytecode-array-builder.h" |
| 8 #include "src/interpreter/bytecode-array-iterator.h" | 8 #include "src/interpreter/bytecode-array-iterator.h" |
| 9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
| 10 #include "test/unittests/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { | 23 TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { |
| 24 BytecodeArrayBuilder builder(isolate(), zone()); | 24 BytecodeArrayBuilder builder(isolate(), zone()); |
| 25 | 25 |
| 26 builder.set_locals_count(131); | 26 builder.set_locals_count(131); |
| 27 builder.set_context_count(1); | 27 builder.set_context_count(1); |
| 28 builder.set_parameter_count(0); | 28 builder.set_parameter_count(0); |
| 29 CHECK_EQ(builder.locals_count(), 131); | 29 CHECK_EQ(builder.locals_count(), 131); |
| 30 CHECK_EQ(builder.context_count(), 1); | 30 CHECK_EQ(builder.context_count(), 1); |
| 31 CHECK_EQ(builder.fixed_register_count(), 132); | 31 CHECK_EQ(builder.fixed_register_count(), 132); |
| 32 | 32 |
| 33 // Emit argument creation operations. CreateRestArguments should |
| 34 // be output before any bytecodes that change constant pool. |
| 35 builder.CreateArguments(CreateArgumentsType::kMappedArguments) |
| 36 .CreateArguments(CreateArgumentsType::kUnmappedArguments) |
| 37 .CreateRestArguments(0); |
| 38 |
| 33 // Emit constant loads. | 39 // Emit constant loads. |
| 34 builder.LoadLiteral(Smi::FromInt(0)) | 40 builder.LoadLiteral(Smi::FromInt(0)) |
| 35 .LoadLiteral(Smi::FromInt(8)) | 41 .LoadLiteral(Smi::FromInt(8)) |
| 36 .LoadLiteral(Smi::FromInt(10000000)) | 42 .LoadLiteral(Smi::FromInt(10000000)) |
| 37 .LoadUndefined() | 43 .LoadUndefined() |
| 38 .LoadNull() | 44 .LoadNull() |
| 39 .LoadTheHole() | 45 .LoadTheHole() |
| 40 .LoadTrue() | 46 .LoadTrue() |
| 41 .LoadFalse(); | 47 .LoadFalse(); |
| 42 | 48 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 .LoadLookupSlot(name, TypeofMode::INSIDE_TYPEOF) | 90 .LoadLookupSlot(name, TypeofMode::INSIDE_TYPEOF) |
| 85 .StoreLookupSlot(name, LanguageMode::SLOPPY) | 91 .StoreLookupSlot(name, LanguageMode::SLOPPY) |
| 86 .StoreLookupSlot(name, LanguageMode::STRICT); | 92 .StoreLookupSlot(name, LanguageMode::STRICT); |
| 87 | 93 |
| 88 // Emit closure operations. | 94 // Emit closure operations. |
| 89 Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo( | 95 Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo( |
| 90 factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>(), | 96 factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>(), |
| 91 false); | 97 false); |
| 92 builder.CreateClosure(shared_info, NOT_TENURED); | 98 builder.CreateClosure(shared_info, NOT_TENURED); |
| 93 | 99 |
| 94 // Emit argument creation operations. | |
| 95 builder.CreateArguments(CreateArgumentsType::kMappedArguments) | |
| 96 .CreateArguments(CreateArgumentsType::kUnmappedArguments); | |
| 97 | |
| 98 // Emit literal creation operations. | 100 // Emit literal creation operations. |
| 99 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0) | 101 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0) |
| 100 .CreateArrayLiteral(factory->NewFixedArray(1), 0, 0) | 102 .CreateArrayLiteral(factory->NewFixedArray(1), 0, 0) |
| 101 .CreateObjectLiteral(factory->NewFixedArray(1), 0, 0); | 103 .CreateObjectLiteral(factory->NewFixedArray(1), 0, 0); |
| 102 | 104 |
| 103 // Call operations. | 105 // Call operations. |
| 104 builder.Call(reg, other, 1, 0) | 106 builder.Call(reg, other, 1, 0) |
| 105 .Call(reg, wide, 1, 0) | 107 .Call(reg, wide, 1, 0) |
| 106 .CallRuntime(Runtime::kIsArray, reg, 1) | 108 .CallRuntime(Runtime::kIsArray, reg, 1) |
| 107 .CallRuntime(Runtime::kIsArray, wide, 1) | 109 .CallRuntime(Runtime::kIsArray, wide, 1) |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 iterator.Advance(); | 683 iterator.Advance(); |
| 682 } | 684 } |
| 683 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 685 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
| 684 iterator.Advance(); | 686 iterator.Advance(); |
| 685 CHECK(iterator.done()); | 687 CHECK(iterator.done()); |
| 686 } | 688 } |
| 687 | 689 |
| 688 } // namespace interpreter | 690 } // namespace interpreter |
| 689 } // namespace internal | 691 } // namespace internal |
| 690 } // namespace v8 | 692 } // namespace v8 |
| OLD | NEW |