| 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 "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| 11 #include "src/interpreter/bytecode-generator.h" | 11 #include "src/interpreter/bytecode-generator.h" |
| 12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
| 13 #include "src/zone.h" | 13 #include "src/zone.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 namespace interpreter { | 17 namespace interpreter { |
| 18 | 18 |
| 19 using compiler::Node; | 19 using compiler::Node; |
| 20 typedef compiler::InterpreterAssembler::SaveAccumulatorMode SaveAccumulatorMode; |
| 21 |
| 20 #define __ assembler-> | 22 #define __ assembler-> |
| 21 | 23 |
| 22 | 24 |
| 23 Interpreter::Interpreter(Isolate* isolate) | 25 Interpreter::Interpreter(Isolate* isolate) |
| 24 : isolate_(isolate) {} | 26 : isolate_(isolate) {} |
| 25 | 27 |
| 26 | 28 |
| 27 // static | 29 // static |
| 28 Handle<FixedArray> Interpreter::CreateUninitializedInterpreterTable( | 30 Handle<FixedArray> Interpreter::CreateUninitializedInterpreterTable( |
| 29 Isolate* isolate) { | 31 Isolate* isolate) { |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 340 |
| 339 // Store the global via the StoreIC. | 341 // Store the global via the StoreIC. |
| 340 Node* code_target = __ HeapConstant(ic.code()); | 342 Node* code_target = __ HeapConstant(ic.code()); |
| 341 Node* constant_index = __ BytecodeOperandIdx(0); | 343 Node* constant_index = __ BytecodeOperandIdx(0); |
| 342 Node* name = __ LoadConstantPoolEntry(constant_index); | 344 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 343 Node* value = __ GetAccumulator(); | 345 Node* value = __ GetAccumulator(); |
| 344 Node* raw_slot = __ BytecodeOperandIdx(1); | 346 Node* raw_slot = __ BytecodeOperandIdx(1); |
| 345 Node* smi_slot = __ SmiTag(raw_slot); | 347 Node* smi_slot = __ SmiTag(raw_slot); |
| 346 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 348 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 347 __ CallIC(ic.descriptor(), code_target, global, name, value, smi_slot, | 349 __ CallIC(ic.descriptor(), code_target, global, name, value, smi_slot, |
| 348 type_feedback_vector); | 350 type_feedback_vector, SaveAccumulatorMode::kSaveAccumulator); |
| 349 | 351 |
| 350 __ Dispatch(); | 352 __ Dispatch(); |
| 351 } | 353 } |
| 352 | 354 |
| 353 | 355 |
| 354 // StaGlobalSloppy <name_index> <slot> | 356 // StaGlobalSloppy <name_index> <slot> |
| 355 // | 357 // |
| 356 // Store the value in the accumulator into the global with name in constant pool | 358 // Store the value in the accumulator into the global with name in constant pool |
| 357 // entry <name_index> using FeedBackVector slot <slot> in sloppy mode. | 359 // entry <name_index> using FeedBackVector slot <slot> in sloppy mode. |
| 358 void Interpreter::DoStaGlobalSloppy(compiler::InterpreterAssembler* assembler) { | 360 void Interpreter::DoStaGlobalSloppy(compiler::InterpreterAssembler* assembler) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 Node* code_target = __ HeapConstant(ic.code()); | 557 Node* code_target = __ HeapConstant(ic.code()); |
| 556 Node* object_reg_index = __ BytecodeOperandReg(0); | 558 Node* object_reg_index = __ BytecodeOperandReg(0); |
| 557 Node* object = __ LoadRegister(object_reg_index); | 559 Node* object = __ LoadRegister(object_reg_index); |
| 558 Node* constant_index = __ BytecodeOperandIdx(1); | 560 Node* constant_index = __ BytecodeOperandIdx(1); |
| 559 Node* name = __ LoadConstantPoolEntry(constant_index); | 561 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 560 Node* value = __ GetAccumulator(); | 562 Node* value = __ GetAccumulator(); |
| 561 Node* raw_slot = __ BytecodeOperandIdx(2); | 563 Node* raw_slot = __ BytecodeOperandIdx(2); |
| 562 Node* smi_slot = __ SmiTag(raw_slot); | 564 Node* smi_slot = __ SmiTag(raw_slot); |
| 563 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 565 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 564 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, | 566 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, |
| 565 type_feedback_vector); | 567 type_feedback_vector, SaveAccumulatorMode::kSaveAccumulator); |
| 566 __ Dispatch(); | 568 __ Dispatch(); |
| 567 } | 569 } |
| 568 | 570 |
| 569 | 571 |
| 570 // StoreICSloppy <object> <name_index> <slot> | 572 // StoreICSloppy <object> <name_index> <slot> |
| 571 // | 573 // |
| 572 // Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and | 574 // Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and |
| 573 // the name in constant pool entry <name_index> with the value in the | 575 // the name in constant pool entry <name_index> with the value in the |
| 574 // accumulator. | 576 // accumulator. |
| 575 void Interpreter::DoStoreICSloppy(compiler::InterpreterAssembler* assembler) { | 577 void Interpreter::DoStoreICSloppy(compiler::InterpreterAssembler* assembler) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 Node* code_target = __ HeapConstant(ic.code()); | 624 Node* code_target = __ HeapConstant(ic.code()); |
| 623 Node* object_reg_index = __ BytecodeOperandReg(0); | 625 Node* object_reg_index = __ BytecodeOperandReg(0); |
| 624 Node* object = __ LoadRegister(object_reg_index); | 626 Node* object = __ LoadRegister(object_reg_index); |
| 625 Node* name_reg_index = __ BytecodeOperandReg(1); | 627 Node* name_reg_index = __ BytecodeOperandReg(1); |
| 626 Node* name = __ LoadRegister(name_reg_index); | 628 Node* name = __ LoadRegister(name_reg_index); |
| 627 Node* value = __ GetAccumulator(); | 629 Node* value = __ GetAccumulator(); |
| 628 Node* raw_slot = __ BytecodeOperandIdx(2); | 630 Node* raw_slot = __ BytecodeOperandIdx(2); |
| 629 Node* smi_slot = __ SmiTag(raw_slot); | 631 Node* smi_slot = __ SmiTag(raw_slot); |
| 630 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 632 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 631 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, | 633 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, |
| 632 type_feedback_vector); | 634 type_feedback_vector, SaveAccumulatorMode::kSaveAccumulator); |
| 633 __ Dispatch(); | 635 __ Dispatch(); |
| 634 } | 636 } |
| 635 | 637 |
| 636 | 638 |
| 637 // KeyedStoreICSloppy <object> <key> <slot> | 639 // KeyedStoreICSloppy <object> <key> <slot> |
| 638 // | 640 // |
| 639 // Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object> | 641 // Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object> |
| 640 // and the key <key> with the value in the accumulator. | 642 // and the key <key> with the value in the accumulator. |
| 641 void Interpreter::DoKeyedStoreICSloppy( | 643 void Interpreter::DoKeyedStoreICSloppy( |
| 642 compiler::InterpreterAssembler* assembler) { | 644 compiler::InterpreterAssembler* assembler) { |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 } | 1194 } |
| 1193 | 1195 |
| 1194 | 1196 |
| 1195 // JumpIfToBooleanTrue <imm8> | 1197 // JumpIfToBooleanTrue <imm8> |
| 1196 // | 1198 // |
| 1197 // Jump by number of bytes represented by an immediate operand if the object | 1199 // Jump by number of bytes represented by an immediate operand if the object |
| 1198 // referenced by the accumulator is true when the object is cast to boolean. | 1200 // referenced by the accumulator is true when the object is cast to boolean. |
| 1199 void Interpreter::DoJumpIfToBooleanTrue( | 1201 void Interpreter::DoJumpIfToBooleanTrue( |
| 1200 compiler::InterpreterAssembler* assembler) { | 1202 compiler::InterpreterAssembler* assembler) { |
| 1201 Node* accumulator = __ GetAccumulator(); | 1203 Node* accumulator = __ GetAccumulator(); |
| 1204 Node* to_boolean_value = |
| 1205 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1206 SaveAccumulatorMode::kSaveAccumulator); |
| 1202 Node* relative_jump = __ BytecodeOperandImm(0); | 1207 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1203 Node* to_boolean_value = | |
| 1204 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
| 1205 Node* true_value = __ BooleanConstant(true); | 1208 Node* true_value = __ BooleanConstant(true); |
| 1206 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1209 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
| 1207 } | 1210 } |
| 1208 | 1211 |
| 1209 | 1212 |
| 1210 // JumpIfToBooleanTrueConstant <idx> | 1213 // JumpIfToBooleanTrueConstant <idx> |
| 1211 // | 1214 // |
| 1212 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1215 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1213 // if the object referenced by the accumulator is true when the object is cast | 1216 // if the object referenced by the accumulator is true when the object is cast |
| 1214 // to boolean. | 1217 // to boolean. |
| 1215 void Interpreter::DoJumpIfToBooleanTrueConstant( | 1218 void Interpreter::DoJumpIfToBooleanTrueConstant( |
| 1216 compiler::InterpreterAssembler* assembler) { | 1219 compiler::InterpreterAssembler* assembler) { |
| 1217 Node* accumulator = __ GetAccumulator(); | 1220 Node* accumulator = __ GetAccumulator(); |
| 1218 Node* to_boolean_value = | 1221 Node* to_boolean_value = |
| 1219 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 1222 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1223 SaveAccumulatorMode::kSaveAccumulator); |
| 1220 Node* index = __ BytecodeOperandIdx(0); | 1224 Node* index = __ BytecodeOperandIdx(0); |
| 1221 Node* constant = __ LoadConstantPoolEntry(index); | 1225 Node* constant = __ LoadConstantPoolEntry(index); |
| 1222 Node* relative_jump = __ SmiUntag(constant); | 1226 Node* relative_jump = __ SmiUntag(constant); |
| 1223 Node* true_value = __ BooleanConstant(true); | 1227 Node* true_value = __ BooleanConstant(true); |
| 1224 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1228 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
| 1225 } | 1229 } |
| 1226 | 1230 |
| 1227 | 1231 |
| 1228 // JumpIfToBooleanFalse <imm8> | 1232 // JumpIfToBooleanFalse <imm8> |
| 1229 // | 1233 // |
| 1230 // Jump by number of bytes represented by an immediate operand if the object | 1234 // Jump by number of bytes represented by an immediate operand if the object |
| 1231 // referenced by the accumulator is false when the object is cast to boolean. | 1235 // referenced by the accumulator is false when the object is cast to boolean. |
| 1232 void Interpreter::DoJumpIfToBooleanFalse( | 1236 void Interpreter::DoJumpIfToBooleanFalse( |
| 1233 compiler::InterpreterAssembler* assembler) { | 1237 compiler::InterpreterAssembler* assembler) { |
| 1234 Node* accumulator = __ GetAccumulator(); | 1238 Node* accumulator = __ GetAccumulator(); |
| 1239 Node* to_boolean_value = |
| 1240 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1241 SaveAccumulatorMode::kSaveAccumulator); |
| 1235 Node* relative_jump = __ BytecodeOperandImm(0); | 1242 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1236 Node* to_boolean_value = | |
| 1237 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
| 1238 Node* false_value = __ BooleanConstant(false); | 1243 Node* false_value = __ BooleanConstant(false); |
| 1239 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1244 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
| 1240 } | 1245 } |
| 1241 | 1246 |
| 1242 | 1247 |
| 1243 // JumpIfToBooleanFalseConstant <idx> | 1248 // JumpIfToBooleanFalseConstant <idx> |
| 1244 // | 1249 // |
| 1245 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1250 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1246 // if the object referenced by the accumulator is false when the object is cast | 1251 // if the object referenced by the accumulator is false when the object is cast |
| 1247 // to boolean. | 1252 // to boolean. |
| 1248 void Interpreter::DoJumpIfToBooleanFalseConstant( | 1253 void Interpreter::DoJumpIfToBooleanFalseConstant( |
| 1249 compiler::InterpreterAssembler* assembler) { | 1254 compiler::InterpreterAssembler* assembler) { |
| 1250 Node* accumulator = __ GetAccumulator(); | 1255 Node* accumulator = __ GetAccumulator(); |
| 1251 Node* to_boolean_value = | 1256 Node* to_boolean_value = |
| 1252 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 1257 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1258 SaveAccumulatorMode::kSaveAccumulator); |
| 1253 Node* index = __ BytecodeOperandIdx(0); | 1259 Node* index = __ BytecodeOperandIdx(0); |
| 1254 Node* constant = __ LoadConstantPoolEntry(index); | 1260 Node* constant = __ LoadConstantPoolEntry(index); |
| 1255 Node* relative_jump = __ SmiUntag(constant); | 1261 Node* relative_jump = __ SmiUntag(constant); |
| 1256 Node* false_value = __ BooleanConstant(false); | 1262 Node* false_value = __ BooleanConstant(false); |
| 1257 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1263 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
| 1258 } | 1264 } |
| 1259 | 1265 |
| 1260 | 1266 |
| 1261 // JumpIfNull <imm8> | 1267 // JumpIfNull <imm8> |
| 1262 // | 1268 // |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); | 1483 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); |
| 1478 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); | 1484 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
| 1479 __ SetAccumulator(result); | 1485 __ SetAccumulator(result); |
| 1480 __ Dispatch(); | 1486 __ Dispatch(); |
| 1481 } | 1487 } |
| 1482 | 1488 |
| 1483 | 1489 |
| 1484 } // namespace interpreter | 1490 } // namespace interpreter |
| 1485 } // namespace internal | 1491 } // namespace internal |
| 1486 } // namespace v8 | 1492 } // namespace v8 |
| OLD | NEW |