Commit 52fd3c1e authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm] [asm.js] Avoid expensive GetLineNumber up front in asm-typer.

In switching to incremental parsing, we switched to pre-computing
line numbers for forward declarations. This is expensive,
because GetLineNumber reparses lines.

Also, switch typing maps to unordered_map (as they appear hot).

BUG=v8:4203
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2553033002
Cr-Commit-Position: refs/heads/master@{#41525}
parent fdc0aa0c
......@@ -189,8 +189,6 @@ AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script,
local_scope_(ZoneHashMap::kDefaultHashMapCapacity,
ZoneAllocationPolicy(zone)),
stack_limit_(isolate->stack_guard()->real_climit()),
module_node_types_(zone_),
function_node_types_(zone_),
fround_type_(AsmType::FroundType(zone_)),
ffi_type_(AsmType::FFIType(zone_)),
function_pointer_tables_(zone_) {
......@@ -399,9 +397,7 @@ AsmTyper::VariableInfo* AsmTyper::Lookup(Variable* variable) const {
}
void AsmTyper::AddForwardReference(VariableProxy* proxy, VariableInfo* info) {
info->SetFirstForwardUse(proxy->position() == kNoSourcePosition
? -1
: script_->GetLineNumber(proxy->position()));
info->SetFirstForwardUse(proxy->position());
forward_definitions_.push_back(info);
}
......@@ -709,8 +705,11 @@ AsmType* AsmTyper::ValidateModuleAfterFunctionsPhase(FunctionLiteral* fun) {
for (auto* forward_def : forward_definitions_) {
if (forward_def->missing_definition()) {
FAIL_LINE(forward_def->source_location(),
"Missing definition for forward declared identifier.");
int position = forward_def->source_location();
int line =
position == kNoSourcePosition ? -1 : script_->GetLineNumber(position);
FAIL_LINE(line, "Missing definition for forward declared identifier.");
}
}
......
......@@ -7,6 +7,7 @@
#include <cstdint>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include "src/allocation.h"
......@@ -390,8 +391,8 @@ class AsmTyper final {
std::uintptr_t stack_limit_;
bool stack_overflow_ = false;
ZoneMap<AstNode*, AsmType*> module_node_types_;
ZoneMap<AstNode*, AsmType*> function_node_types_;
std::unordered_map<AstNode*, AsmType*> module_node_types_;
std::unordered_map<AstNode*, AsmType*> function_node_types_;
static const int kErrorMessageLimit = 128;
AsmType* fround_type_;
AsmType* ffi_type_;
......
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