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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. 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
« no previous file with comments | « src/asmjs/asm-typer.h ('k') | src/asmjs/asm-wasm-builder.cc » ('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 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // ---------------------------------------------------------------------------- 121 // ----------------------------------------------------------------------------
122 // Implementation of AsmTyper 122 // Implementation of AsmTyper
123 123
124 AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script, 124 AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script,
125 FunctionLiteral* root) 125 FunctionLiteral* root)
126 : isolate_(isolate), 126 : isolate_(isolate),
127 zone_(zone), 127 zone_(zone),
128 script_(script), 128 script_(script),
129 root_(root), 129 root_(root),
130 forward_definitions_(zone), 130 forward_definitions_(zone),
131 ffi_use_signatures_(zone),
131 stdlib_types_(zone), 132 stdlib_types_(zone),
132 stdlib_math_types_(zone), 133 stdlib_math_types_(zone),
133 module_info_(VariableInfo::ForSpecialSymbol(zone_, kModule)), 134 module_info_(VariableInfo::ForSpecialSymbol(zone_, kModule)),
134 global_scope_(ZoneHashMap::PointersMatch, 135 global_scope_(ZoneHashMap::PointersMatch,
135 ZoneHashMap::kDefaultHashMapCapacity, 136 ZoneHashMap::kDefaultHashMapCapacity,
136 ZoneAllocationPolicy(zone)), 137 ZoneAllocationPolicy(zone)),
137 local_scope_(ZoneHashMap::PointersMatch, 138 local_scope_(ZoneHashMap::PointersMatch,
138 ZoneHashMap::kDefaultHashMapCapacity, 139 ZoneHashMap::kDefaultHashMapCapacity,
139 ZoneAllocationPolicy(zone)), 140 ZoneAllocationPolicy(zone)),
140 stack_limit_(isolate->stack_guard()->real_climit()), 141 stack_limit_(isolate->stack_guard()->real_climit()),
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 323
323 std::unique_ptr<char[]> aname = key->AsPropertyName()->ToCString(); 324 std::unique_ptr<char[]> aname = key->AsPropertyName()->ToCString();
324 ObjectTypeMap::iterator i = stdlib->find(std::string(aname.get())); 325 ObjectTypeMap::iterator i = stdlib->find(std::string(aname.get()));
325 if (i == stdlib->end()) { 326 if (i == stdlib->end()) {
326 return nullptr; 327 return nullptr;
327 } 328 }
328 stdlib_uses_.insert(i->second->standard_member()); 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) const {
333 ZoneHashMap* scope = in_function_ ? &local_scope_ : &global_scope_; 334 const 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 }
339 340
340 if (entry == nullptr && !module_name_.is_null() && 341 if (entry == nullptr && !module_name_.is_null() &&
341 module_name_->Equals(*variable->name())) { 342 module_name_->Equals(*variable->name())) {
342 return module_info_; 343 return module_info_;
343 } 344 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 417 }
417 int32_t i; 418 int32_t i;
418 if (literal->value()->ToInt32(&i)) { 419 if (literal->value()->ToInt32(&i)) {
419 return AsmType::Signed(); 420 return AsmType::Signed();
420 } 421 }
421 } 422 }
422 423
423 return AsmType::None(); 424 return AsmType::None();
424 } 425 }
425 426
427 AsmType* AsmTyper::TypeOf(Variable* v) const { return Lookup(v)->type(); }
428
426 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) { 429 AsmTyper::StandardMember AsmTyper::VariableAsStandardMember(Variable* var) {
427 auto* var_info = Lookup(var); 430 auto* var_info = Lookup(var);
428 if (var_info == nullptr) { 431 if (var_info == nullptr) {
429 return kNone; 432 return kNone;
430 } 433 }
431 StandardMember member = var_info->standard_member(); 434 StandardMember member = var_info->standard_member();
432 return member; 435 return member;
433 } 436 }
434 437
435 bool AsmTyper::Validate() { 438 bool AsmTyper::Validate() {
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 SetTypeOf(call_var_proxy, reinterpret_cast<AsmType*>(call_type)); 2302 SetTypeOf(call_var_proxy, reinterpret_cast<AsmType*>(call_type));
2300 SetTypeOf(call, return_type); 2303 SetTypeOf(call, return_type);
2301 return return_type; 2304 return return_type;
2302 } 2305 }
2303 2306
2304 auto* callee_type = call_var_info->type()->AsCallableType(); 2307 auto* callee_type = call_var_info->type()->AsCallableType();
2305 if (callee_type == nullptr) { 2308 if (callee_type == nullptr) {
2306 FAIL(call, "Calling something that's not a function."); 2309 FAIL(call, "Calling something that's not a function.");
2307 } 2310 }
2308 2311
2309 if (callee_type->AsFFIType() != nullptr && 2312 if (callee_type->AsFFIType() != nullptr) {
2310 return_type == AsmType::Float()) { 2313 if (return_type == AsmType::Float()) {
2311 FAIL(call, "Foreign functions can't return float."); 2314 FAIL(call, "Foreign functions can't return float.");
2315 }
2316 // Record FFI use signature, since the asm->wasm translator must know
2317 // all uses up-front.
2318 ffi_use_signatures_.emplace_back(
2319 FFIUseSignature(call_var_proxy->var(), zone_));
2320 FFIUseSignature* sig = &ffi_use_signatures_.back();
2321 sig->return_type_ = return_type;
2322 sig->arg_types_.reserve(args.size());
2323 for (size_t i = 0; i < args.size(); ++i) {
2324 sig->arg_types_.emplace_back(args[i]);
2325 }
2312 } 2326 }
2313 2327
2314 if (!callee_type->CanBeInvokedWith(return_type, args)) { 2328 if (!callee_type->CanBeInvokedWith(return_type, args)) {
2315 FAIL(call, "Function invocation does not match function type."); 2329 FAIL(call, "Function invocation does not match function type.");
2316 } 2330 }
2317 2331
2318 SetTypeOf(call_var_proxy, call_var_info->type()); 2332 SetTypeOf(call_var_proxy, call_var_info->type());
2319 SetTypeOf(call, return_type); 2333 SetTypeOf(call, return_type);
2320 return return_type; 2334 return return_type;
2321 } 2335 }
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 return true; 2779 return true;
2766 } 2780 }
2767 2781
2768 *error_message = typer.error_message(); 2782 *error_message = typer.error_message();
2769 return false; 2783 return false;
2770 } 2784 }
2771 2785
2772 } // namespace wasm 2786 } // namespace wasm
2773 } // namespace internal 2787 } // namespace internal
2774 } // namespace v8 2788 } // namespace v8
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.h ('k') | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698