Chromium Code Reviews| 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; | |
|
Michael Starzinger
2015/12/09 18:16:22
nit: Would "using compiler::InterpreterAssembler::
rmcilroy
2015/12/10 14:17:12
No, that didn't work (can't remember why). Removed
| |
| 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 } | 1183 } |
| 1182 | 1184 |
| 1183 | 1185 |
| 1184 // JumpIfToBooleanTrue <imm8> | 1186 // JumpIfToBooleanTrue <imm8> |
| 1185 // | 1187 // |
| 1186 // Jump by number of bytes represented by an immediate operand if the object | 1188 // Jump by number of bytes represented by an immediate operand if the object |
| 1187 // referenced by the accumulator is true when the object is cast to boolean. | 1189 // referenced by the accumulator is true when the object is cast to boolean. |
| 1188 void Interpreter::DoJumpIfToBooleanTrue( | 1190 void Interpreter::DoJumpIfToBooleanTrue( |
| 1189 compiler::InterpreterAssembler* assembler) { | 1191 compiler::InterpreterAssembler* assembler) { |
| 1190 Node* accumulator = __ GetAccumulator(); | 1192 Node* accumulator = __ GetAccumulator(); |
| 1193 Node* to_boolean_value = | |
| 1194 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, | |
|
Michael Starzinger
2015/12/09 18:16:22
We assume that this bytecode is safe with the deop
rmcilroy
2015/12/10 14:17:12
Removed accumulator spilling (note the accumulator
| |
| 1195 SaveAccumulatorMode::kSaveAccumulator); | |
| 1191 Node* relative_jump = __ BytecodeOperandImm(0); | 1196 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1192 Node* to_boolean_value = | |
| 1193 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
| 1194 Node* true_value = __ BooleanConstant(true); | 1197 Node* true_value = __ BooleanConstant(true); |
| 1195 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1198 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
| 1196 } | 1199 } |
| 1197 | 1200 |
| 1198 | 1201 |
| 1199 // JumpIfToBooleanTrueConstant <idx> | 1202 // JumpIfToBooleanTrueConstant <idx> |
| 1200 // | 1203 // |
| 1201 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1204 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1202 // if the object referenced by the accumulator is true when the object is cast | 1205 // if the object referenced by the accumulator is true when the object is cast |
| 1203 // to boolean. | 1206 // to boolean. |
| 1204 void Interpreter::DoJumpIfToBooleanTrueConstant( | 1207 void Interpreter::DoJumpIfToBooleanTrueConstant( |
| 1205 compiler::InterpreterAssembler* assembler) { | 1208 compiler::InterpreterAssembler* assembler) { |
| 1206 Node* accumulator = __ GetAccumulator(); | 1209 Node* accumulator = __ GetAccumulator(); |
| 1207 Node* to_boolean_value = | 1210 Node* to_boolean_value = |
| 1208 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 1211 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1212 SaveAccumulatorMode::kSaveAccumulator); | |
| 1209 Node* index = __ BytecodeOperandIdx(0); | 1213 Node* index = __ BytecodeOperandIdx(0); |
| 1210 Node* constant = __ LoadConstantPoolEntry(index); | 1214 Node* constant = __ LoadConstantPoolEntry(index); |
| 1211 Node* relative_jump = __ SmiUntag(constant); | 1215 Node* relative_jump = __ SmiUntag(constant); |
| 1212 Node* true_value = __ BooleanConstant(true); | 1216 Node* true_value = __ BooleanConstant(true); |
| 1213 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); | 1217 __ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
| 1214 } | 1218 } |
| 1215 | 1219 |
| 1216 | 1220 |
| 1217 // JumpIfToBooleanFalse <imm8> | 1221 // JumpIfToBooleanFalse <imm8> |
| 1218 // | 1222 // |
| 1219 // Jump by number of bytes represented by an immediate operand if the object | 1223 // Jump by number of bytes represented by an immediate operand if the object |
| 1220 // referenced by the accumulator is false when the object is cast to boolean. | 1224 // referenced by the accumulator is false when the object is cast to boolean. |
| 1221 void Interpreter::DoJumpIfToBooleanFalse( | 1225 void Interpreter::DoJumpIfToBooleanFalse( |
| 1222 compiler::InterpreterAssembler* assembler) { | 1226 compiler::InterpreterAssembler* assembler) { |
| 1223 Node* accumulator = __ GetAccumulator(); | 1227 Node* accumulator = __ GetAccumulator(); |
| 1228 Node* to_boolean_value = | |
| 1229 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, | |
| 1230 SaveAccumulatorMode::kSaveAccumulator); | |
| 1224 Node* relative_jump = __ BytecodeOperandImm(0); | 1231 Node* relative_jump = __ BytecodeOperandImm(0); |
| 1225 Node* to_boolean_value = | |
| 1226 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | |
| 1227 Node* false_value = __ BooleanConstant(false); | 1232 Node* false_value = __ BooleanConstant(false); |
| 1228 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1233 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
| 1229 } | 1234 } |
| 1230 | 1235 |
| 1231 | 1236 |
| 1232 // JumpIfToBooleanFalseConstant <idx> | 1237 // JumpIfToBooleanFalseConstant <idx> |
| 1233 // | 1238 // |
| 1234 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool | 1239 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1235 // if the object referenced by the accumulator is false when the object is cast | 1240 // if the object referenced by the accumulator is false when the object is cast |
| 1236 // to boolean. | 1241 // to boolean. |
| 1237 void Interpreter::DoJumpIfToBooleanFalseConstant( | 1242 void Interpreter::DoJumpIfToBooleanFalseConstant( |
| 1238 compiler::InterpreterAssembler* assembler) { | 1243 compiler::InterpreterAssembler* assembler) { |
| 1239 Node* accumulator = __ GetAccumulator(); | 1244 Node* accumulator = __ GetAccumulator(); |
| 1240 Node* to_boolean_value = | 1245 Node* to_boolean_value = |
| 1241 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 1246 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator, |
| 1247 SaveAccumulatorMode::kSaveAccumulator); | |
| 1242 Node* index = __ BytecodeOperandIdx(0); | 1248 Node* index = __ BytecodeOperandIdx(0); |
| 1243 Node* constant = __ LoadConstantPoolEntry(index); | 1249 Node* constant = __ LoadConstantPoolEntry(index); |
| 1244 Node* relative_jump = __ SmiUntag(constant); | 1250 Node* relative_jump = __ SmiUntag(constant); |
| 1245 Node* false_value = __ BooleanConstant(false); | 1251 Node* false_value = __ BooleanConstant(false); |
| 1246 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 1252 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
| 1247 } | 1253 } |
| 1248 | 1254 |
| 1249 | 1255 |
| 1250 // JumpIfNull <imm8> | 1256 // JumpIfNull <imm8> |
| 1251 // | 1257 // |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1497 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); | 1503 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); |
| 1498 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); | 1504 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
| 1499 __ SetAccumulator(result); | 1505 __ SetAccumulator(result); |
| 1500 __ Dispatch(); | 1506 __ Dispatch(); |
| 1501 } | 1507 } |
| 1502 | 1508 |
| 1503 | 1509 |
| 1504 } // namespace interpreter | 1510 } // namespace interpreter |
| 1505 } // namespace internal | 1511 } // namespace internal |
| 1506 } // namespace v8 | 1512 } // namespace v8 |
| OLD | NEW |