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

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

Issue 2615443003: Forbid non-locals/keyed-property calls to allow interleaved compile. (Closed)
Patch Set: fix Created 3 years, 11 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 | test/cctest/asmjs/test-asm-typer.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 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 fun_info->set_mutability(VariableInfo::kImmutableGlobal); 2382 fun_info->set_mutability(VariableInfo::kImmutableGlobal);
2383 AddForwardReference(call_var_proxy, fun_info); 2383 AddForwardReference(call_var_proxy, fun_info);
2384 if (!ValidAsmIdentifier(call_var_proxy->name())) { 2384 if (!ValidAsmIdentifier(call_var_proxy->name())) {
2385 FAIL(call_var_proxy, 2385 FAIL(call_var_proxy,
2386 "Invalid asm.js identifier in (forward) function name."); 2386 "Invalid asm.js identifier in (forward) function name.");
2387 } 2387 }
2388 if (!AddGlobal(call_var_proxy->var(), fun_info)) { 2388 if (!AddGlobal(call_var_proxy->var(), fun_info)) {
2389 DCHECK(false); 2389 DCHECK(false);
2390 FAIL(call, "Redeclared global identifier."); 2390 FAIL(call, "Redeclared global identifier.");
2391 } 2391 }
2392 if (call->GetCallType() != Call::OTHER_CALL) {
2393 FAIL(call, "Invalid call of existing global function.");
2394 }
2392 SetTypeOf(call_var_proxy, reinterpret_cast<AsmType*>(call_type)); 2395 SetTypeOf(call_var_proxy, reinterpret_cast<AsmType*>(call_type));
2393 SetTypeOf(call, return_type); 2396 SetTypeOf(call, return_type);
2394 return return_type; 2397 return return_type;
2395 } 2398 }
2396 2399
2397 auto* callee_type = call_var_info->type()->AsCallableType(); 2400 auto* callee_type = call_var_info->type()->AsCallableType();
2398 if (callee_type == nullptr) { 2401 if (callee_type == nullptr) {
2399 FAIL(call, "Calling something that's not a function."); 2402 FAIL(call, "Calling something that's not a function.");
2400 } 2403 }
2401 2404
(...skipping 10 matching lines...) Expand all
2412 sig->arg_types_.reserve(args.size()); 2415 sig->arg_types_.reserve(args.size());
2413 for (size_t i = 0; i < args.size(); ++i) { 2416 for (size_t i = 0; i < args.size(); ++i) {
2414 sig->arg_types_.emplace_back(args[i]); 2417 sig->arg_types_.emplace_back(args[i]);
2415 } 2418 }
2416 } 2419 }
2417 2420
2418 if (!callee_type->CanBeInvokedWith(return_type, args)) { 2421 if (!callee_type->CanBeInvokedWith(return_type, args)) {
2419 FAIL(call, "Function invocation does not match function type."); 2422 FAIL(call, "Function invocation does not match function type.");
2420 } 2423 }
2421 2424
2425 if (call->GetCallType() != Call::OTHER_CALL) {
2426 FAIL(call, "Invalid forward call of global function.");
2427 }
2428
2422 SetTypeOf(call_var_proxy, call_var_info->type()); 2429 SetTypeOf(call_var_proxy, call_var_info->type());
2423 SetTypeOf(call, return_type); 2430 SetTypeOf(call, return_type);
2424 return return_type; 2431 return return_type;
2425 } 2432 }
2426 2433
2427 // identifier[expr & n](Expression...) 2434 // identifier[expr & n](Expression...)
2428 if (auto* call_property = call_expr->AsProperty()) { 2435 if (auto* call_property = call_expr->AsProperty()) {
2429 auto* index = call_property->key()->AsBinaryOperation(); 2436 auto* index = call_property->key()->AsBinaryOperation();
2430 if (index == nullptr || index->op() != Token::BIT_AND) { 2437 if (index == nullptr || index->op() != Token::BIT_AND) {
2431 FAIL(call_property->key(), 2438 FAIL(call_property->key(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 fun_info->set_mutability(VariableInfo::kImmutableGlobal); 2477 fun_info->set_mutability(VariableInfo::kImmutableGlobal);
2471 AddForwardReference(name_var, fun_info); 2478 AddForwardReference(name_var, fun_info);
2472 if (!ValidAsmIdentifier(name_var->name())) { 2479 if (!ValidAsmIdentifier(name_var->name())) {
2473 FAIL(name_var, 2480 FAIL(name_var,
2474 "Invalid asm.js identifier in (forward) function table name."); 2481 "Invalid asm.js identifier in (forward) function table name.");
2475 } 2482 }
2476 if (!AddGlobal(name_var->var(), fun_info)) { 2483 if (!AddGlobal(name_var->var(), fun_info)) {
2477 DCHECK(false); 2484 DCHECK(false);
2478 FAIL(call, "Redeclared global identifier."); 2485 FAIL(call, "Redeclared global identifier.");
2479 } 2486 }
2487 if (call->GetCallType() != Call::KEYED_PROPERTY_CALL) {
2488 FAIL(call, "Invalid call of existing function table.");
2489 }
2480 SetTypeOf(call_property, reinterpret_cast<AsmType*>(call_type)); 2490 SetTypeOf(call_property, reinterpret_cast<AsmType*>(call_type));
2481 SetTypeOf(call, return_type); 2491 SetTypeOf(call, return_type);
2482 return return_type; 2492 return return_type;
2483 } 2493 }
2484 2494
2485 auto* previous_type = name_info->type()->AsFunctionTableType(); 2495 auto* previous_type = name_info->type()->AsFunctionTableType();
2486 if (previous_type == nullptr) { 2496 if (previous_type == nullptr) {
2487 FAIL(call, "Identifier does not name a function table."); 2497 FAIL(call, "Identifier does not name a function table.");
2488 } 2498 }
2489 2499
2490 if (table_length != previous_type->length()) { 2500 if (table_length != previous_type->length()) {
2491 FAIL(call, "Function table size does not match expected size."); 2501 FAIL(call, "Function table size does not match expected size.");
2492 } 2502 }
2493 2503
2494 auto* previous_type_signature = 2504 auto* previous_type_signature =
2495 previous_type->signature()->AsFunctionType(); 2505 previous_type->signature()->AsFunctionType();
2496 DCHECK(previous_type_signature != nullptr); 2506 DCHECK(previous_type_signature != nullptr);
2497 if (!previous_type_signature->CanBeInvokedWith(return_type, args)) { 2507 if (!previous_type_signature->CanBeInvokedWith(return_type, args)) {
2498 // TODO(jpp): better error messages. 2508 // TODO(jpp): better error messages.
2499 FAIL(call, 2509 FAIL(call,
2500 "Function pointer table signature does not match previous " 2510 "Function pointer table signature does not match previous "
2501 "signature."); 2511 "signature.");
2502 } 2512 }
2503 2513
2514 if (call->GetCallType() != Call::KEYED_PROPERTY_CALL) {
2515 FAIL(call, "Invalid forward call of function table.");
2516 }
2504 SetTypeOf(call_property, previous_type->signature()); 2517 SetTypeOf(call_property, previous_type->signature());
2505 SetTypeOf(call, return_type); 2518 SetTypeOf(call, return_type);
2506 return return_type; 2519 return return_type;
2507 } 2520 }
2508 2521
2509 FAIL(call, "Invalid call."); 2522 FAIL(call, "Invalid call.");
2510 } 2523 }
2511 2524
2512 // 6.10 ValidateHeapAccess 2525 // 6.10 ValidateHeapAccess
2513 namespace { 2526 namespace {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 "Heap view creation parameter should be the module's heap parameter."); 2923 "Heap view creation parameter should be the module's heap parameter.");
2911 } 2924 }
2912 2925
2913 DCHECK(heap_view_info->type()->IsA(AsmType::Heap())); 2926 DCHECK(heap_view_info->type()->IsA(AsmType::Heap()));
2914 return heap_view_info->type(); 2927 return heap_view_info->type();
2915 } 2928 }
2916 2929
2917 } // namespace wasm 2930 } // namespace wasm
2918 } // namespace internal 2931 } // namespace internal
2919 } // namespace v8 2932 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/asmjs/test-asm-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698