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

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2377903002: [wasm] [asm.js] Fix various asm.js issues. (Closed)
Patch Set: Created 4 years, 2 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
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/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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 current_function_builder_->EmitCode(code, sizeof(code)); 614 current_function_builder_->EmitCode(code, sizeof(code));
615 } else if (type->IsA(AsmType::Int())) { 615 } else if (type->IsA(AsmType::Int())) {
616 // The parser can collapse !0, !1 etc to true / false. 616 // The parser can collapse !0, !1 etc to true / false.
617 // Allow these as int literals. 617 // Allow these as int literals.
618 if (expr->raw_value()->IsTrue()) { 618 if (expr->raw_value()->IsTrue()) {
619 byte code[] = {WASM_I32V(1)}; 619 byte code[] = {WASM_I32V(1)};
620 current_function_builder_->EmitCode(code, sizeof(code)); 620 current_function_builder_->EmitCode(code, sizeof(code));
621 } else if (expr->raw_value()->IsFalse()) { 621 } else if (expr->raw_value()->IsFalse()) {
622 byte code[] = {WASM_I32V(0)}; 622 byte code[] = {WASM_I32V(0)};
623 current_function_builder_->EmitCode(code, sizeof(code)); 623 current_function_builder_->EmitCode(code, sizeof(code));
624 } else if (expr->raw_value()->IsNumber()) {
625 // This can happen when -x becomes x * -1 (due to the parser).
626 int32_t i = 0;
627 if (!value->ToInt32(&i) || i != -1) {
628 UNREACHABLE();
629 }
630 byte code[] = {WASM_I32V(i)};
631 current_function_builder_->EmitCode(code, sizeof(code));
624 } else { 632 } else {
625 UNREACHABLE(); 633 UNREACHABLE();
626 } 634 }
627 } else if (type->IsA(AsmType::Double())) { 635 } else if (type->IsA(AsmType::Double())) {
636 // TODO(bradnelson): Pattern match the case where negation occurs and
637 // emit f64.neg instead.
628 double val = expr->raw_value()->AsNumber(); 638 double val = expr->raw_value()->AsNumber();
629 byte code[] = {WASM_F64(val)}; 639 byte code[] = {WASM_F64(val)};
630 current_function_builder_->EmitCode(code, sizeof(code)); 640 current_function_builder_->EmitCode(code, sizeof(code));
641 } else if (type->IsA(AsmType::Float())) {
642 // This can happen when -fround(x) becomes fround(x) * 1.0[float]
643 // (due to the parser).
644 // TODO(bradnelson): Pattern match this and emit f32.neg instead.
645 double val = expr->raw_value()->AsNumber();
646 DCHECK_EQ(-1.0, val);
647 byte code[] = {WASM_F32(val)};
648 current_function_builder_->EmitCode(code, sizeof(code));
631 } else { 649 } else {
632 UNREACHABLE(); 650 UNREACHABLE();
633 } 651 }
634 } 652 }
635 653
636 void VisitRegExpLiteral(RegExpLiteral* expr) { UNREACHABLE(); } 654 void VisitRegExpLiteral(RegExpLiteral* expr) { UNREACHABLE(); }
637 655
638 void VisitObjectLiteral(ObjectLiteral* expr) { 656 void VisitObjectLiteral(ObjectLiteral* expr) {
639 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 657 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
640 for (int i = 0; i < props->length(); ++i) { 658 for (int i = 0; i < props->length(); ++i) {
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 impl.builder_->WriteTo(*buffer); 1919 impl.builder_->WriteTo(*buffer);
1902 return buffer; 1920 return buffer;
1903 } 1921 }
1904 1922
1905 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1923 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1906 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 1924 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1907 1925
1908 } // namespace wasm 1926 } // namespace wasm
1909 } // namespace internal 1927 } // namespace internal
1910 } // namespace v8 1928 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698