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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Factory* factory = isolate()->factory(); | 97 Factory* factory = isolate()->factory(); |
98 Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo( | 98 Handle<SharedFunctionInfo> shared_info = factory->NewSharedFunctionInfo( |
99 factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>(), | 99 factory->NewStringFromStaticChars("function_a"), MaybeHandle<Code>(), |
100 false); | 100 false); |
101 builder.CreateClosure(shared_info, NOT_TENURED); | 101 builder.CreateClosure(shared_info, NOT_TENURED); |
102 | 102 |
103 // Emit argument creation operations. | 103 // Emit argument creation operations. |
104 builder.CreateArguments(CreateArgumentsType::kMappedArguments) | 104 builder.CreateArguments(CreateArgumentsType::kMappedArguments) |
105 .CreateArguments(CreateArgumentsType::kUnmappedArguments); | 105 .CreateArguments(CreateArgumentsType::kUnmappedArguments); |
106 | 106 |
107 // Emit literal creation operations | 107 // Emit literal creation operations. |
108 builder.CreateRegExpLiteral(0, 0) | 108 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0) |
109 .CreateArrayLiteral(0, 0) | 109 .CreateArrayLiteral(factory->NewFixedArray(1), 0, 0) |
110 .CreateObjectLiteral(0, 0); | 110 .CreateObjectLiteral(factory->NewFixedArray(1), 0, 0); |
111 | 111 |
112 // Call operations. | 112 // Call operations. |
113 builder.Call(reg, reg, 0, 0) | 113 builder.Call(reg, reg, 0, 0) |
114 .Call(reg, reg, 0, 1024) | 114 .Call(reg, reg, 0, 1024) |
115 .CallRuntime(Runtime::kIsArray, reg, 1) | 115 .CallRuntime(Runtime::kIsArray, reg, 1) |
116 .CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg, 1); | 116 .CallJSRuntime(Context::SPREAD_ITERABLE_INDEX, reg, 1); |
117 | 117 |
118 // Emit binary operator invocations. | 118 // Emit binary operator invocations. |
119 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) | 119 builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK) |
120 .BinaryOperation(Token::Value::SUB, reg, Strength::WEAK) | 120 .BinaryOperation(Token::Value::SUB, reg, Strength::WEAK) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 builder.GetConstantPoolEntry(handle(Smi::FromInt(i), isolate())); | 218 builder.GetConstantPoolEntry(handle(Smi::FromInt(i), isolate())); |
219 } | 219 } |
220 builder.LoadLiteral(Smi::FromInt(20000000)); | 220 builder.LoadLiteral(Smi::FromInt(20000000)); |
221 | 221 |
222 // CreateClosureWide | 222 // CreateClosureWide |
223 Handle<SharedFunctionInfo> shared_info2 = factory->NewSharedFunctionInfo( | 223 Handle<SharedFunctionInfo> shared_info2 = factory->NewSharedFunctionInfo( |
224 factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>(), | 224 factory->NewStringFromStaticChars("function_b"), MaybeHandle<Code>(), |
225 false); | 225 false); |
226 builder.CreateClosure(shared_info2, NOT_TENURED); | 226 builder.CreateClosure(shared_info2, NOT_TENURED); |
227 | 227 |
| 228 // Emit wide variant of literal creation operations. |
| 229 builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("wide_literal"), |
| 230 0, 0) |
| 231 .CreateArrayLiteral(factory->NewFixedArray(2), 0, 0) |
| 232 .CreateObjectLiteral(factory->NewFixedArray(2), 0, 0); |
| 233 |
228 builder.Return(); | 234 builder.Return(); |
229 | 235 |
230 // Generate BytecodeArray. | 236 // Generate BytecodeArray. |
231 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); | 237 Handle<BytecodeArray> the_array = builder.ToBytecodeArray(); |
232 CHECK_EQ(the_array->frame_size(), | 238 CHECK_EQ(the_array->frame_size(), |
233 builder.fixed_register_count() * kPointerSize); | 239 builder.fixed_register_count() * kPointerSize); |
234 | 240 |
235 // Build scorecard of bytecodes encountered in the BytecodeArray. | 241 // Build scorecard of bytecodes encountered in the BytecodeArray. |
236 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); | 242 std::vector<int> scorecard(Bytecodes::ToByte(Bytecode::kLast) + 1); |
237 Bytecode final_bytecode = Bytecode::kLdaZero; | 243 Bytecode final_bytecode = Bytecode::kLdaZero; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 722 |
717 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); | 723 CHECK_EQ(iterator.current_bytecode(), Bytecode::kReturn); |
718 iterator.Advance(); | 724 iterator.Advance(); |
719 CHECK(iterator.done()); | 725 CHECK(iterator.done()); |
720 } | 726 } |
721 | 727 |
722 | 728 |
723 } // namespace interpreter | 729 } // namespace interpreter |
724 } // namespace internal | 730 } // namespace internal |
725 } // namespace v8 | 731 } // namespace v8 |
OLD | NEW |