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

Side by Side Diff: src/asmjs/asm-typer.cc

Issue 2264913002: [wasm] asm.js - Remove Wasm.instantiateModuleFromAsm, use asm.js directly. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/asmjs/asm-typer.h" 5 #include "src/asmjs/asm-typer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (obj_info->IsFFI()) { 319 if (obj_info->IsFFI()) {
320 // For FFI we can't validate import->key, so assume this is OK. 320 // For FFI we can't validate import->key, so assume this is OK.
321 return obj_info; 321 return obj_info;
322 } 322 }
323 323
324 std::unique_ptr<char[]> aname = key->AsPropertyName()->ToCString(); 324 std::unique_ptr<char[]> aname = key->AsPropertyName()->ToCString();
325 ObjectTypeMap::iterator i = stdlib->find(std::string(aname.get())); 325 ObjectTypeMap::iterator i = stdlib->find(std::string(aname.get()));
326 if (i == stdlib->end()) { 326 if (i == stdlib->end()) {
327 return nullptr; 327 return nullptr;
328 } 328 }
329 stdlib_uses_.insert(i->second->standard_member());
329 return i->second; 330 return i->second;
330 } 331 }
331 332
332 AsmTyper::VariableInfo* AsmTyper::Lookup(Variable* variable) { 333 AsmTyper::VariableInfo* AsmTyper::Lookup(Variable* variable) {
333 ZoneHashMap* scope = in_function_ ? &local_scope_ : &global_scope_; 334 ZoneHashMap* scope = in_function_ ? &local_scope_ : &global_scope_;
334 ZoneHashMap::Entry* entry = 335 ZoneHashMap::Entry* entry =
335 scope->Lookup(variable, ComputePointerHash(variable)); 336 scope->Lookup(variable, ComputePointerHash(variable));
336 if (entry == nullptr && in_function_) { 337 if (entry == nullptr && in_function_) {
337 entry = global_scope_.Lookup(variable, ComputePointerHash(variable)); 338 entry = global_scope_.Lookup(variable, ComputePointerHash(variable));
338 } 339 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 423
423 return AsmType::None(); 424 return AsmType::None();
424 } 425 }
425 426
426 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) { 427 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) {
427 auto* var_info = Lookup(var); 428 auto* var_info = Lookup(var);
428 if (var_info == nullptr) { 429 if (var_info == nullptr) {
429 return kNone; 430 return kNone;
430 } 431 }
431 StandardMember member = var_info->standard_member(); 432 StandardMember member = var_info->standard_member();
432 stdlib_uses_.insert(member);
433 return member; 433 return member;
434 } 434 }
435 435
436 bool AsmTyper::Validate() { 436 bool AsmTyper::Validate() {
437 if (!AsmType::None()->IsExactly(ValidateModule(root_))) { 437 if (!AsmType::None()->IsExactly(ValidateModule(root_))) {
438 return true; 438 return true;
439 } 439 }
440 return false; 440 return false;
441 } 441 }
442 442
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 zone_, kModuleParamInfo[ii].standard_member); 590 zone_, kModuleParamInfo[ii].standard_member);
591 591
592 if (!AddGlobal(param, param_info)) { 592 if (!AddGlobal(param, param_info)) {
593 FAIL(fun, "Redeclared identifier in module parameter."); 593 FAIL(fun, "Redeclared identifier in module parameter.");
594 } 594 }
595 } 595 }
596 596
597 ZoneVector<Assignment*> function_pointer_tables(zone_); 597 ZoneVector<Assignment*> function_pointer_tables(zone_);
598 FlattenedStatements iter(zone_, fun->body()); 598 FlattenedStatements iter(zone_, fun->body());
599 auto* use_asm_directive = iter.Next(); 599 auto* use_asm_directive = iter.Next();
600 if (use_asm_directive == nullptr || !IsUseAsmDirective(use_asm_directive)) { 600 if (use_asm_directive == nullptr) {
601 FAIL(fun, "Missing \"use asm\".");
602 }
603 // Check for extra assignment inserted by the parser when in this form:
604 // (function Module(a, b, c) {... })
605 ExpressionStatement* estatement = use_asm_directive->AsExpressionStatement();
606 if (estatement != nullptr) {
607 Assignment* assignment = estatement->expression()->AsAssignment();
608 if (assignment != nullptr && assignment->target()->IsVariableProxy() &&
609 assignment->target()->AsVariableProxy()->var()->mode() ==
610 CONST_LEGACY) {
611 use_asm_directive = iter.Next();
612 }
613 }
614 if (!IsUseAsmDirective(use_asm_directive)) {
601 FAIL(fun, "Missing \"use asm\"."); 615 FAIL(fun, "Missing \"use asm\".");
602 } 616 }
603 source_layout.AddUseAsm(*use_asm_directive); 617 source_layout.AddUseAsm(*use_asm_directive);
604 ReturnStatement* module_return = nullptr; 618 ReturnStatement* module_return = nullptr;
605 619
606 // *VIOLATION* The spec states that globals should be followed by function 620 // *VIOLATION* The spec states that globals should be followed by function
607 // declarations, which should be followed by function pointer tables, followed 621 // declarations, which should be followed by function pointer tables, followed
608 // by the module export (return) statement. Our AST might be rearraged by the 622 // by the module export (return) statement. Our AST might be rearraged by the
609 // parser, so we can't rely on it being in source code order. 623 // parser, so we can't rely on it being in source code order.
610 while (Statement* current = iter.Next()) { 624 while (Statement* current = iter.Next()) {
(...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 return true; 2760 return true;
2747 } 2761 }
2748 2762
2749 *error_message = typer.error_message(); 2763 *error_message = typer.error_message();
2750 return false; 2764 return false;
2751 } 2765 }
2752 2766
2753 } // namespace wasm 2767 } // namespace wasm
2754 } // namespace internal 2768 } // namespace internal
2755 } // namespace v8 2769 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698