| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 // Required to get M_E etc. in MSVC. | 7 // Required to get M_E etc. in MSVC. |
| 8 #if defined(_WIN32) | 8 #if defined(_WIN32) |
| 9 #define _USE_MATH_DEFINES | 9 #define _USE_MATH_DEFINES |
| 10 #endif | 10 #endif |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 sig.AddReturn(return_type); | 1352 sig.AddReturn(return_type); |
| 1353 } else { | 1353 } else { |
| 1354 returns_value = false; | 1354 returns_value = false; |
| 1355 } | 1355 } |
| 1356 for (int i = 0; i < args->length(); ++i) { | 1356 for (int i = 0; i < args->length(); ++i) { |
| 1357 sig.AddParam(TypeOf(args->at(i))); | 1357 sig.AddParam(TypeOf(args->at(i))); |
| 1358 } | 1358 } |
| 1359 uint32_t index = imported_function_table_.LookupOrInsertImport( | 1359 uint32_t index = imported_function_table_.LookupOrInsertImport( |
| 1360 vp->var(), sig.Build()); | 1360 vp->var(), sig.Build()); |
| 1361 VisitCallArgs(expr); | 1361 VisitCallArgs(expr); |
| 1362 current_function_builder_->AddAsmWasmOffset(expr->position()); |
| 1362 current_function_builder_->Emit(kExprCallFunction); | 1363 current_function_builder_->Emit(kExprCallFunction); |
| 1363 current_function_builder_->EmitVarInt(index); | 1364 current_function_builder_->EmitVarInt(index); |
| 1364 } else { | 1365 } else { |
| 1365 WasmFunctionBuilder* function = LookupOrInsertFunction(vp->var()); | 1366 WasmFunctionBuilder* function = LookupOrInsertFunction(vp->var()); |
| 1366 VisitCallArgs(expr); | 1367 VisitCallArgs(expr); |
| 1368 current_function_builder_->AddAsmWasmOffset(expr->position()); |
| 1367 current_function_builder_->Emit(kExprCallFunction); | 1369 current_function_builder_->Emit(kExprCallFunction); |
| 1368 current_function_builder_->EmitDirectCallIndex( | 1370 current_function_builder_->EmitDirectCallIndex( |
| 1369 function->func_index()); | 1371 function->func_index()); |
| 1370 returns_value = function->signature()->return_count() > 0; | 1372 returns_value = function->signature()->return_count() > 0; |
| 1371 } | 1373 } |
| 1372 break; | 1374 break; |
| 1373 } | 1375 } |
| 1374 case Call::KEYED_PROPERTY_CALL: { | 1376 case Call::KEYED_PROPERTY_CALL: { |
| 1375 DCHECK_EQ(kFuncScope, scope_); | 1377 DCHECK_EQ(kFuncScope, scope_); |
| 1376 Property* p = expr->expression()->AsProperty(); | 1378 Property* p = expr->expression()->AsProperty(); |
| 1377 DCHECK_NOT_NULL(p); | 1379 DCHECK_NOT_NULL(p); |
| 1378 VariableProxy* var = p->obj()->AsVariableProxy(); | 1380 VariableProxy* var = p->obj()->AsVariableProxy(); |
| 1379 DCHECK_NOT_NULL(var); | 1381 DCHECK_NOT_NULL(var); |
| 1380 FunctionTableIndices* indices = LookupFunctionTable(var->var()); | 1382 FunctionTableIndices* indices = LookupFunctionTable(var->var()); |
| 1381 Visit(p->key()); // TODO(titzer): should use RECURSE() | 1383 Visit(p->key()); // TODO(titzer): should use RECURSE() |
| 1382 | 1384 |
| 1383 // We have to use a temporary for the correct order of evaluation. | 1385 // We have to use a temporary for the correct order of evaluation. |
| 1384 current_function_builder_->EmitI32Const(indices->start_index); | 1386 current_function_builder_->EmitI32Const(indices->start_index); |
| 1385 current_function_builder_->Emit(kExprI32Add); | 1387 current_function_builder_->Emit(kExprI32Add); |
| 1386 WasmTemporary tmp(current_function_builder_, kAstI32); | 1388 WasmTemporary tmp(current_function_builder_, kAstI32); |
| 1387 current_function_builder_->EmitSetLocal(tmp.index()); | 1389 current_function_builder_->EmitSetLocal(tmp.index()); |
| 1388 | 1390 |
| 1389 VisitCallArgs(expr); | 1391 VisitCallArgs(expr); |
| 1390 | 1392 |
| 1391 current_function_builder_->EmitGetLocal(tmp.index()); | 1393 current_function_builder_->EmitGetLocal(tmp.index()); |
| 1394 current_function_builder_->AddAsmWasmOffset(expr->position()); |
| 1392 current_function_builder_->Emit(kExprCallIndirect); | 1395 current_function_builder_->Emit(kExprCallIndirect); |
| 1393 current_function_builder_->EmitVarInt(indices->signature_index); | 1396 current_function_builder_->EmitVarInt(indices->signature_index); |
| 1394 returns_value = | 1397 returns_value = |
| 1395 builder_->GetSignature(indices->signature_index)->return_count() > | 1398 builder_->GetSignature(indices->signature_index)->return_count() > |
| 1396 0; | 1399 0; |
| 1397 break; | 1400 break; |
| 1398 } | 1401 } |
| 1399 default: | 1402 default: |
| 1400 UNREACHABLE(); | 1403 UNREACHABLE(); |
| 1401 } | 1404 } |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 impl.builder_->WriteTo(*buffer); | 1881 impl.builder_->WriteTo(*buffer); |
| 1879 return buffer; | 1882 return buffer; |
| 1880 } | 1883 } |
| 1881 | 1884 |
| 1882 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; | 1885 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; |
| 1883 const char* AsmWasmBuilder::single_function_name = "__single_function__"; | 1886 const char* AsmWasmBuilder::single_function_name = "__single_function__"; |
| 1884 | 1887 |
| 1885 } // namespace wasm | 1888 } // namespace wasm |
| 1886 } // namespace internal | 1889 } // namespace internal |
| 1887 } // namespace v8 | 1890 } // namespace v8 |
| OLD | NEW |