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

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

Issue 2348383003: [wasm] Support asm.js modules with a single function. (Closed)
Patch Set: Created 4 years, 3 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/asmjs/asm-js.cc ('k') | test/mjsunit/wasm/asm-wasm.js » ('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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 kExprGetGlobal, 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 } else if (scope_ == kExportScope) {
555 Variable* var = expr->var();
556 DCHECK(var->is_function());
557 uint32_t index = LookupOrInsertFunction(var);
558 builder_->FunctionAt(index)->SetExported();
559 std::string raw_name = "__single_function__";
Mircea Trofin 2016/09/19 18:42:29 could we have these centrally defined?
bradn 2016/09/19 20:30:38 Done.
560 builder_->FunctionAt(index)->SetName(
561 reinterpret_cast<const char*>(raw_name.data()), raw_name.length());
554 } 562 }
555 } 563 }
556 564
557 void VisitLiteral(Literal* expr) { 565 void VisitLiteral(Literal* expr) {
558 Handle<Object> value = expr->value(); 566 Handle<Object> value = expr->value();
559 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) { 567 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) {
560 return; 568 return;
561 } 569 }
562 AsmType* type = typer_->TypeOf(expr); 570 AsmType* type = typer_->TypeOf(expr);
563 DCHECK_NE(type, AsmType::None()); 571 DCHECK_NE(type, AsmType::None());
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); 1796 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_);
1789 impl.Build(); 1797 impl.Build();
1790 *foreign_args = impl.GetForeignArgs(); 1798 *foreign_args = impl.GetForeignArgs();
1791 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); 1799 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_);
1792 impl.builder_->WriteTo(*buffer); 1800 impl.builder_->WriteTo(*buffer);
1793 return buffer; 1801 return buffer;
1794 } 1802 }
1795 } // namespace wasm 1803 } // namespace wasm
1796 } // namespace internal 1804 } // namespace internal
1797 } // namespace v8 1805 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-js.cc ('k') | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698