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

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

Issue 2209433002: [wasm] Make LoadGlobal/StoreGlobal opcodes match what is coming in binary 0xC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | src/compiler/wasm-compiler.h » ('j') | 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/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 builder_->FunctionAt(foreign_init_function_index_); 91 builder_->FunctionAt(foreign_init_function_index_);
92 current_function_builder_->SetExported(); 92 current_function_builder_->SetExported();
93 std::string raw_name = "__foreign_init__"; 93 std::string raw_name = "__foreign_init__";
94 current_function_builder_->SetName(raw_name.data(), 94 current_function_builder_->SetName(raw_name.data(),
95 static_cast<int>(raw_name.size())); 95 static_cast<int>(raw_name.size()));
96 current_function_builder_->SetSignature(b.Build()); 96 current_function_builder_->SetSignature(b.Build());
97 for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) { 97 for (size_t pos = 0; pos < foreign_variables_.size(); ++pos) {
98 current_function_builder_->EmitGetLocal(static_cast<uint32_t>(pos)); 98 current_function_builder_->EmitGetLocal(static_cast<uint32_t>(pos));
99 ForeignVariable* fv = &foreign_variables_[pos]; 99 ForeignVariable* fv = &foreign_variables_[pos];
100 uint32_t index = LookupOrInsertGlobal(fv->var, fv->type); 100 uint32_t index = LookupOrInsertGlobal(fv->var, fv->type);
101 current_function_builder_->EmitWithVarInt(kExprStoreGlobal, index); 101 current_function_builder_->EmitWithVarInt(kExprSetGlobal, index);
102 } 102 }
103 current_function_builder_ = nullptr; 103 current_function_builder_ = nullptr;
104 } 104 }
105 105
106 i::Handle<i::FixedArray> GetForeignArgs() { 106 i::Handle<i::FixedArray> GetForeignArgs() {
107 i::Handle<FixedArray> ret = isolate_->factory()->NewFixedArray( 107 i::Handle<FixedArray> ret = isolate_->factory()->NewFixedArray(
108 static_cast<int>(foreign_variables_.size())); 108 static_cast<int>(foreign_variables_.size()));
109 for (size_t i = 0; i < foreign_variables_.size(); ++i) { 109 for (size_t i = 0; i < foreign_variables_.size(); ++i) {
110 ForeignVariable* fv = &foreign_variables_[i]; 110 ForeignVariable* fv = &foreign_variables_[i];
111 ret->set(static_cast<int>(i), *fv->name); 111 ret->set(static_cast<int>(i), *fv->name);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 void VisitVariableProxy(VariableProxy* expr) { 539 void VisitVariableProxy(VariableProxy* expr) {
540 if (scope_ == kFuncScope || scope_ == kInitScope) { 540 if (scope_ == kFuncScope || scope_ == kInitScope) {
541 Variable* var = expr->var(); 541 Variable* var = expr->var();
542 if (VisitStdlibConstant(var)) { 542 if (VisitStdlibConstant(var)) {
543 return; 543 return;
544 } 544 }
545 LocalType var_type = TypeOf(expr); 545 LocalType var_type = TypeOf(expr);
546 DCHECK_NE(kAstStmt, var_type); 546 DCHECK_NE(kAstStmt, var_type);
547 if (var->IsContextSlot()) { 547 if (var->IsContextSlot()) {
548 current_function_builder_->EmitWithVarInt( 548 current_function_builder_->EmitWithVarInt(
549 kExprLoadGlobal, LookupOrInsertGlobal(var, var_type)); 549 kExprGetGlobal, LookupOrInsertGlobal(var, var_type));
550 } else { 550 } else {
551 current_function_builder_->EmitGetLocal( 551 current_function_builder_->EmitGetLocal(
552 LookupOrInsertLocal(var, var_type)); 552 LookupOrInsertLocal(var, var_type));
553 } 553 }
554 } 554 }
555 } 555 }
556 556
557 void VisitLiteral(Literal* expr) { 557 void VisitLiteral(Literal* expr) {
558 Handle<Object> value = expr->value(); 558 Handle<Object> value = expr->value();
559 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) { 559 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 void EmitAssignment(Assignment* expr, MachineType type) { 777 void EmitAssignment(Assignment* expr, MachineType type) {
778 // Match the left hand side of the assignment. 778 // Match the left hand side of the assignment.
779 VariableProxy* target_var = expr->target()->AsVariableProxy(); 779 VariableProxy* target_var = expr->target()->AsVariableProxy();
780 if (target_var != nullptr) { 780 if (target_var != nullptr) {
781 // Left hand side is a local or a global variable. 781 // Left hand side is a local or a global variable.
782 Variable* var = target_var->var(); 782 Variable* var = target_var->var();
783 LocalType var_type = TypeOf(expr); 783 LocalType var_type = TypeOf(expr);
784 DCHECK_NE(kAstStmt, var_type); 784 DCHECK_NE(kAstStmt, var_type);
785 if (var->IsContextSlot()) { 785 if (var->IsContextSlot()) {
786 current_function_builder_->EmitWithVarInt( 786 current_function_builder_->EmitWithVarInt(
787 kExprStoreGlobal, LookupOrInsertGlobal(var, var_type)); 787 kExprSetGlobal, LookupOrInsertGlobal(var, var_type));
788 } else { 788 } else {
789 current_function_builder_->EmitSetLocal( 789 current_function_builder_->EmitSetLocal(
790 LookupOrInsertLocal(var, var_type)); 790 LookupOrInsertLocal(var, var_type));
791 } 791 }
792 } 792 }
793 793
794 Property* target_prop = expr->target()->AsProperty(); 794 Property* target_prop = expr->target()->AsProperty();
795 if (target_prop != nullptr) { 795 if (target_prop != nullptr) {
796 // Left hand side is a property access, i.e. the asm.js heap. 796 // Left hand side is a property access, i.e. the asm.js heap.
797 if (TypeOf(expr->value()) == kAstF64 && expr->target()->IsProperty() && 797 if (TypeOf(expr->value()) == kAstF64 && expr->target()->IsProperty() &&
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); 1782 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_);
1783 impl.Build(); 1783 impl.Build();
1784 *foreign_args = impl.GetForeignArgs(); 1784 *foreign_args = impl.GetForeignArgs();
1785 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); 1785 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_);
1786 impl.builder_->WriteTo(*buffer); 1786 impl.builder_->WriteTo(*buffer);
1787 return buffer; 1787 return buffer;
1788 } 1788 }
1789 } // namespace wasm 1789 } // namespace wasm
1790 } // namespace internal 1790 } // namespace internal
1791 } // namespace v8 1791 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/wasm-compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698