Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1736643003: [Interpreter] Use existing type conversion stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast/prettyprinter.h" 7 #include "src/ast/prettyprinter.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 1217
1218 1218
1219 // TestInstanceOf <src> 1219 // TestInstanceOf <src>
1220 // 1220 //
1221 // Test if the object referenced by the <src> register is an an instance of type 1221 // Test if the object referenced by the <src> register is an an instance of type
1222 // referenced by the accumulator. 1222 // referenced by the accumulator.
1223 void Interpreter::DoTestInstanceOf(InterpreterAssembler* assembler) { 1223 void Interpreter::DoTestInstanceOf(InterpreterAssembler* assembler) {
1224 DoBinaryOp(Runtime::kInstanceOf, assembler); 1224 DoBinaryOp(Runtime::kInstanceOf, assembler);
1225 } 1225 }
1226 1226
1227 void Interpreter::DoTypeConversionOp(Callable callable,
1228 InterpreterAssembler* assembler) {
1229 Node* target = __ HeapConstant(callable.code());
1230 Node* accumulator = __ GetAccumulator();
1231 Node* context = __ GetContext();
1232 Node* result =
1233 __ CallStub(callable.descriptor(), target, context, accumulator);
1234 __ SetAccumulator(result);
1235 __ Dispatch();
1236 }
1227 1237
1228 // ToName 1238 // ToName
1229 // 1239 //
1230 // Cast the object referenced by the accumulator to a name. 1240 // Cast the object referenced by the accumulator to a name.
1231 void Interpreter::DoToName(InterpreterAssembler* assembler) { 1241 void Interpreter::DoToName(InterpreterAssembler* assembler) {
1232 Node* accumulator = __ GetAccumulator(); 1242 DoTypeConversionOp(CodeFactory::ToName(isolate_), assembler);
1233 Node* context = __ GetContext();
1234 Node* result = __ CallRuntime(Runtime::kToName, context, accumulator);
1235 __ SetAccumulator(result);
1236 __ Dispatch();
1237 } 1243 }
1238 1244
1239 1245
1240 // ToNumber 1246 // ToNumber
1241 // 1247 //
1242 // Cast the object referenced by the accumulator to a number. 1248 // Cast the object referenced by the accumulator to a number.
1243 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { 1249 void Interpreter::DoToNumber(InterpreterAssembler* assembler) {
1244 Node* accumulator = __ GetAccumulator(); 1250 DoTypeConversionOp(CodeFactory::ToNumber(isolate_), assembler);
1245 Node* context = __ GetContext();
1246 Node* result = __ CallRuntime(Runtime::kToNumber, context, accumulator);
1247 __ SetAccumulator(result);
1248 __ Dispatch();
1249 } 1251 }
1250 1252
1251 1253
1252 // ToObject 1254 // ToObject
1253 // 1255 //
1254 // Cast the object referenced by the accumulator to a JSObject. 1256 // Cast the object referenced by the accumulator to a JSObject.
1255 void Interpreter::DoToObject(InterpreterAssembler* assembler) { 1257 void Interpreter::DoToObject(InterpreterAssembler* assembler) {
1256 Node* accumulator = __ GetAccumulator(); 1258 DoTypeConversionOp(CodeFactory::ToObject(isolate_), assembler);
1257 Node* context = __ GetContext();
1258 Node* result = __ CallRuntime(Runtime::kToObject, context, accumulator);
1259 __ SetAccumulator(result);
1260 __ Dispatch();
1261 } 1259 }
1262 1260
1263 1261
1264 // Jump <imm8> 1262 // Jump <imm8>
1265 // 1263 //
1266 // Jump by number of bytes represented by the immediate operand |imm8|. 1264 // Jump by number of bytes represented by the immediate operand |imm8|.
1267 void Interpreter::DoJump(InterpreterAssembler* assembler) { 1265 void Interpreter::DoJump(InterpreterAssembler* assembler) {
1268 Node* relative_jump = __ BytecodeOperandImm(0); 1266 Node* relative_jump = __ BytecodeOperandImm(0);
1269 __ Jump(relative_jump); 1267 __ Jump(relative_jump);
1270 } 1268 }
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 Node* index = __ LoadRegister(index_reg); 1838 Node* index = __ LoadRegister(index_reg);
1841 Node* context = __ GetContext(); 1839 Node* context = __ GetContext();
1842 Node* result = __ CallRuntime(Runtime::kForInStep, context, index); 1840 Node* result = __ CallRuntime(Runtime::kForInStep, context, index);
1843 __ SetAccumulator(result); 1841 __ SetAccumulator(result);
1844 __ Dispatch(); 1842 __ Dispatch();
1845 } 1843 }
1846 1844
1847 } // namespace interpreter 1845 } // namespace interpreter
1848 } // namespace internal 1846 } // namespace internal
1849 } // namespace v8 1847 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698