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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 void VisitLiteral(Literal* expr) { | 463 void VisitLiteral(Literal* expr) { |
464 Handle<Object> value = expr->value(); | 464 Handle<Object> value = expr->value(); |
465 if (!in_function_ || !value->IsNumber()) { | 465 if (!in_function_ || !value->IsNumber()) { |
466 return; | 466 return; |
467 } | 467 } |
468 Type* type = expr->bounds().upper; | 468 Type* type = expr->bounds().upper; |
469 if (type->Is(cache_.kAsmSigned)) { | 469 if (type->Is(cache_.kAsmSigned)) { |
470 int32_t i; | 470 int32_t i = 0; |
471 if (!value->ToInt32(&i)) { | 471 if (!value->ToInt32(&i)) { |
472 UNREACHABLE(); | 472 UNREACHABLE(); |
473 } | 473 } |
474 byte code[] = {WASM_I32V(i)}; | 474 byte code[] = {WASM_I32V(i)}; |
475 current_function_builder_->EmitCode(code, sizeof(code)); | 475 current_function_builder_->EmitCode(code, sizeof(code)); |
476 } else if (type->Is(cache_.kAsmUnsigned) || type->Is(cache_.kAsmFixnum)) { | 476 } else if (type->Is(cache_.kAsmUnsigned) || type->Is(cache_.kAsmFixnum)) { |
477 uint32_t u; | 477 uint32_t u = 0; |
478 if (!value->ToUint32(&u)) { | 478 if (!value->ToUint32(&u)) { |
479 UNREACHABLE(); | 479 UNREACHABLE(); |
480 } | 480 } |
481 int32_t i = static_cast<int32_t>(u); | 481 int32_t i = static_cast<int32_t>(u); |
482 byte code[] = {WASM_I32V(i)}; | 482 byte code[] = {WASM_I32V(i)}; |
483 current_function_builder_->EmitCode(code, sizeof(code)); | 483 current_function_builder_->EmitCode(code, sizeof(code)); |
484 } else if (type->Is(cache_.kAsmDouble)) { | 484 } else if (type->Is(cache_.kAsmDouble)) { |
485 double val = expr->raw_value()->AsNumber(); | 485 double val = expr->raw_value()->AsNumber(); |
486 byte code[] = {WASM_F64(val)}; | 486 byte code[] = {WASM_F64(val)}; |
487 current_function_builder_->EmitCode(code, sizeof(code)); | 487 current_function_builder_->EmitCode(code, sizeof(code)); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 // that zone in constructor may be thrown away once wasm module is written. | 1533 // that zone in constructor may be thrown away once wasm module is written. |
1534 WasmModuleIndex* AsmWasmBuilder::Run() { | 1534 WasmModuleIndex* AsmWasmBuilder::Run() { |
1535 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_); | 1535 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_); |
1536 impl.Compile(); | 1536 impl.Compile(); |
1537 WasmModuleWriter* writer = impl.builder_->Build(zone_); | 1537 WasmModuleWriter* writer = impl.builder_->Build(zone_); |
1538 return writer->WriteTo(zone_); | 1538 return writer->WriteTo(zone_); |
1539 } | 1539 } |
1540 } // namespace wasm | 1540 } // namespace wasm |
1541 } // namespace internal | 1541 } // namespace internal |
1542 } // namespace v8 | 1542 } // namespace v8 |
OLD | NEW |