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 "test/unittests/test-utils.h" | 9 #include "test/unittests/test-utils.h" |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 builder.LoadNamedProperty(reg, 2056, 0, LanguageMode::SLOPPY) | 87 builder.LoadNamedProperty(reg, 2056, 0, LanguageMode::SLOPPY) |
88 .LoadKeyedProperty(reg, 2056, LanguageMode::SLOPPY) | 88 .LoadKeyedProperty(reg, 2056, LanguageMode::SLOPPY) |
89 .StoreNamedProperty(reg, 0, 2056, LanguageMode::SLOPPY) | 89 .StoreNamedProperty(reg, 0, 2056, LanguageMode::SLOPPY) |
90 .StoreKeyedProperty(reg, reg, 2056, LanguageMode::SLOPPY) | 90 .StoreKeyedProperty(reg, reg, 2056, LanguageMode::SLOPPY) |
91 .LoadNamedProperty(reg, 2056, 0, LanguageMode::STRICT) | 91 .LoadNamedProperty(reg, 2056, 0, LanguageMode::STRICT) |
92 .LoadKeyedProperty(reg, 2056, LanguageMode::STRICT) | 92 .LoadKeyedProperty(reg, 2056, LanguageMode::STRICT) |
93 .StoreNamedProperty(reg, 0, 2056, LanguageMode::STRICT) | 93 .StoreNamedProperty(reg, 0, 2056, LanguageMode::STRICT) |
94 .StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT); | 94 .StoreKeyedProperty(reg, reg, 2056, LanguageMode::STRICT); |
95 | 95 |
96 // Emit closure operations. | 96 // Emit closure operations. |
97 Factory* factory = isolate()->factory(); | 97 builder.CreateClosure(NOT_TENURED); |
98 Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo( | |
99 factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>(), | |
100 false); | |
101 builder.CreateClosure(shared_info, NOT_TENURED); | |
102 | 98 |
103 // Emit argument creation operations. | 99 // Emit argument creation operations. |
104 builder.CreateArguments(CreateArgumentsType::kMappedArguments) | 100 builder.CreateArguments(CreateArgumentsType::kMappedArguments) |
105 .CreateArguments(CreateArgumentsType::kUnmappedArguments); | 101 .CreateArguments(CreateArgumentsType::kUnmappedArguments); |
106 | 102 |
107 // Emit literal creation operations | 103 // Emit literal creation operations |
108 builder.CreateRegExpLiteral(0, reg) | 104 builder.CreateRegExpLiteral(0, reg) |
109 .CreateArrayLiteral(0, 0) | 105 .CreateArrayLiteral(0, 0) |
110 .CreateObjectLiteral(0, 0); | 106 .CreateObjectLiteral(0, 0); |
111 | 107 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 208 |
213 builder.ForInPrepare(reg).ForInDone(reg).ForInNext(reg, reg); | 209 builder.ForInPrepare(reg).ForInDone(reg).ForInNext(reg, reg); |
214 | 210 |
215 // Wide constant pool loads | 211 // Wide constant pool loads |
216 for (int i = 0; i < 256; i++) { | 212 for (int i = 0; i < 256; i++) { |
217 // Emit junk in constant pool to force wide constant pool index. | 213 // Emit junk in constant pool to force wide constant pool index. |
218 builder.GetConstantPoolEntry(handle(Smi::FromInt(i), isolate())); | 214 builder.GetConstantPoolEntry(handle(Smi::FromInt(i), isolate())); |
219 } | 215 } |
220 builder.LoadLiteral(Smi::FromInt(20000000)); | 216 builder.LoadLiteral(Smi::FromInt(20000000)); |
221 | 217 |
222 // CreateClosureWide | |
223 Handle<SharedFunctionInfo> shared_info2 = factory->NewSharedFunctionInfo( | |
224 factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>(), | |
225 false); | |
226 builder.CreateClosure(shared_info2, NOT_TENURED); | |
227 | |
228 builder.Return(); | 218 builder.Return(); |
229 | 219 |
230 // Generate BytecodeArray. | 220 // Generate BytecodeArray. |
231 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 221 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
232 CHECK_EQ(the_array->frame_size(), | 222 CHECK_EQ(the_array->frame_size(), |
233 builder.fixed_register_count() * kPointerSize); | 223 builder.fixed_register_count() * kPointerSize); |
234 | 224 |
235 // Build scorecard of bytecodes encountered in the BytecodeArray. | 225 // Build scorecard of bytecodes encountered in the BytecodeArray. |
236 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); | 226 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); |
237 Bytecode final_bytecode = Bytecode::kLdaZero; | 227 Bytecode final_bytecode = Bytecode::kLdaZero; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 706 |
717 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 707 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
718 iterator.Advance(); | 708 iterator.Advance(); |
719 CHECK(iterator.done()); | 709 CHECK(iterator.done()); |
720 } | 710 } |
721 | 711 |
722 | 712 |
723 } // namespace interpreter | 713 } // namespace interpreter |
724 } // namespace internal | 714 } // namespace internal |
725 } // namespace v8 | 715 } // namespace v8 |
OLD | NEW |