Commit d43cebe7 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[asm.js] Test and fix function name collisions.

R=ahaas@chromium.org
TEST=message/asm-function-variable-collision
BUG=v8:6127

Change-Id: I75658f0bf58a8b3de5eb42f4f054476f8d2c139b
Reviewed-on: https://chromium-review.googlesource.com/469651
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44475}
parent f3b848fe
...@@ -741,9 +741,12 @@ void AsmJsParser::ValidateFunction() { ...@@ -741,9 +741,12 @@ void AsmJsParser::ValidateFunction() {
function_info->kind = VarKind::kFunction; function_info->kind = VarKind::kFunction;
function_info->function_builder = module_builder_->AddFunction(); function_info->function_builder = module_builder_->AddFunction();
function_info->index = function_info->function_builder->func_index(); function_info->index = function_info->function_builder->func_index();
} else if (function_info->kind != VarKind::kFunction) {
FAIL("Function name collides with variable");
} else if (function_info->function_defined) { } else if (function_info->function_defined) {
FAIL("Function redefined"); FAIL("Function redefined");
} }
function_info->function_defined = true; function_info->function_defined = true;
// TODO(bradnelson): Cleanup memory management here. // TODO(bradnelson): Cleanup memory management here.
// WasmModuleBuilder should own these. // WasmModuleBuilder should own these.
...@@ -806,9 +809,6 @@ void AsmJsParser::ValidateFunction() { ...@@ -806,9 +809,6 @@ void AsmJsParser::ValidateFunction() {
function_info->index = current_function_builder_->func_index(); function_info->index = current_function_builder_->func_index();
function_info->type = function_type; function_info->type = function_type;
} else { } else {
if (function_info->kind != VarKind::kFunction) {
FAIL("Function name collides with variable");
}
// TODO(bradnelson): Should IsExactly be used here? // TODO(bradnelson): Should IsExactly be used here?
if (!function_info->type->IsA(AsmType::None()) && if (!function_info->type->IsA(AsmType::None()) &&
!function_type->IsA(function_info->type)) { !function_type->IsA(function_info->type)) {
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --validate-asm --no-stress-opt --no-stress-validate-asm --no-suppress-asm-messages --fast-validate-asm
// Violates asm.js because symbol {f} is defined as module function twice.
function Module() {
"use asm"
function f() {}
function f() {}
return { f:f };
}
Module().f();
# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:12: Invalid asm.js: Function redefined
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --validate-asm --no-stress-opt --no-stress-validate-asm --no-suppress-asm-messages --fast-validate-asm
// Violates asm.js because symbol {f} is used as module variable and function.
function Module() {
"use asm"
var f = 0;
function f() {}
return { f:f };
}
Module();
# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
*%(basename)s:12: Invalid asm.js: Function name collides with variable
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment