| 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 "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Emit accumulator transfers. | 38 // Emit accumulator transfers. |
| 39 Register reg(0); | 39 Register reg(0); |
| 40 builder.LoadAccumulatorWithRegister(reg).StoreAccumulatorInRegister(reg); | 40 builder.LoadAccumulatorWithRegister(reg).StoreAccumulatorInRegister(reg); |
| 41 | 41 |
| 42 // Emit load / store property operations. | 42 // Emit load / store property operations. |
| 43 builder.LoadNamedProperty(reg, 0, LanguageMode::SLOPPY) | 43 builder.LoadNamedProperty(reg, 0, LanguageMode::SLOPPY) |
| 44 .LoadKeyedProperty(reg, 0, LanguageMode::SLOPPY) | 44 .LoadKeyedProperty(reg, 0, LanguageMode::SLOPPY) |
| 45 .StoreNamedProperty(reg, reg, 0, LanguageMode::SLOPPY) | 45 .StoreNamedProperty(reg, reg, 0, LanguageMode::SLOPPY) |
| 46 .StoreKeyedProperty(reg, reg, 0, LanguageMode::SLOPPY); | 46 .StoreKeyedProperty(reg, reg, 0, LanguageMode::SLOPPY); |
| 47 | 47 |
| 48 // Call operations. |
| 49 builder.Call(reg, reg, 0); |
| 50 |
| 48 // Emit binary operators invocations. | 51 // Emit binary operators invocations. |
| 49 builder.BinaryOperation(Token::Value::ADD, reg) | 52 builder.BinaryOperation(Token::Value::ADD, reg) |
| 50 .BinaryOperation(Token::Value::SUB, reg) | 53 .BinaryOperation(Token::Value::SUB, reg) |
| 51 .BinaryOperation(Token::Value::MUL, reg) | 54 .BinaryOperation(Token::Value::MUL, reg) |
| 52 .BinaryOperation(Token::Value::DIV, reg) | 55 .BinaryOperation(Token::Value::DIV, reg) |
| 53 .BinaryOperation(Token::Value::MOD, reg); | 56 .BinaryOperation(Token::Value::MOD, reg); |
| 54 | 57 |
| 55 // Emit control flow. Return must be the last instruction. | 58 // Emit control flow. Return must be the last instruction. |
| 56 builder.Return(); | 59 builder.Return(); |
| 57 | 60 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 .LoadLiteral(heap_num_2_copy); | 176 .LoadLiteral(heap_num_2_copy); |
| 174 | 177 |
| 175 Handle<BytecodeArray> array = builder.ToBytecodeArray(); | 178 Handle<BytecodeArray> array = builder.ToBytecodeArray(); |
| 176 // Should only have one entry for each identical constant. | 179 // Should only have one entry for each identical constant. |
| 177 CHECK_EQ(array->constant_pool()->length(), 3); | 180 CHECK_EQ(array->constant_pool()->length(), 3); |
| 178 } | 181 } |
| 179 | 182 |
| 180 } // namespace interpreter | 183 } // namespace interpreter |
| 181 } // namespace internal | 184 } // namespace internal |
| 182 } // namespace v8 | 185 } // namespace v8 |
| OLD | NEW |