[asm.js] Remove AST-based asm.js validator implementation.

R=clemensh@chromium.org
BUG=v8:6127

Change-Id: I6a098151fef14c0c76c1762d99316a3ae7d12a8e
Reviewed-on: https://chromium-review.googlesource.com/496266
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45119}
This commit is contained in:
Michael Starzinger 2017-05-04 15:25:43 +02:00 committed by Commit Bot
parent 0c590f45a8
commit 2238a16c69
18 changed files with 48 additions and 7581 deletions

View File

@ -1081,12 +1081,8 @@ v8_source_set("v8_base") {
"src/asmjs/asm-parser.h",
"src/asmjs/asm-scanner.cc",
"src/asmjs/asm-scanner.h",
"src/asmjs/asm-typer.cc",
"src/asmjs/asm-typer.h",
"src/asmjs/asm-types.cc",
"src/asmjs/asm-types.h",
"src/asmjs/asm-wasm-builder.cc",
"src/asmjs/asm-wasm-builder.h",
"src/asmjs/switch-logic.cc",
"src/asmjs/switch-logic.h",
"src/assembler-inl.h",

View File

@ -1,5 +1,3 @@
# Keep in sync with test/cctest/asmjs/OWNERS.
set noparent
ahaas@chromium.org

View File

@ -8,9 +8,8 @@
#include "src/api.h"
#include "src/asmjs/asm-names.h"
#include "src/asmjs/asm-parser.h"
#include "src/asmjs/asm-typer.h"
#include "src/asmjs/asm-wasm-builder.h"
#include "src/assert-scope.h"
#include "src/ast/ast.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/compilation-info.h"
#include "src/execution.h"
@ -30,6 +29,8 @@
namespace v8 {
namespace internal {
const char* const AsmJs::kSingleFunctionName = "__single_function__";
namespace {
enum WasmDataEntries {
kWasmDataCompiledModule,
@ -63,18 +64,10 @@ Handle<Object> StdlibMathMember(Isolate* isolate, Handle<JSReceiver> stdlib,
}
bool IsStdlibMemberValid(Isolate* isolate, Handle<JSReceiver> stdlib,
wasm::AsmTyper::StandardMember member,
wasm::AsmJsParser::StandardMember member,
bool* is_typed_array) {
switch (member) {
case wasm::AsmTyper::StandardMember::kNone:
case wasm::AsmTyper::StandardMember::kModule:
case wasm::AsmTyper::StandardMember::kStdlib:
case wasm::AsmTyper::StandardMember::kHeap:
case wasm::AsmTyper::StandardMember::kFFI: {
// Nothing to check for these.
return true;
}
case wasm::AsmTyper::StandardMember::kInfinity: {
case wasm::AsmJsParser::StandardMember::kInfinity: {
if (stdlib.is_null()) {
return false;
}
@ -87,7 +80,7 @@ bool IsStdlibMemberValid(Isolate* isolate, Handle<JSReceiver> stdlib,
Handle<Object> value = maybe_value.ToHandleChecked();
return value->IsNumber() && std::isinf(value->Number());
}
case wasm::AsmTyper::StandardMember::kNaN: {
case wasm::AsmJsParser::StandardMember::kNaN: {
if (stdlib.is_null()) {
return false;
}
@ -101,7 +94,7 @@ bool IsStdlibMemberValid(Isolate* isolate, Handle<JSReceiver> stdlib,
return value->IsNaN();
}
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
case wasm::AsmTyper::StandardMember::kMath##FName: { \
case wasm::AsmJsParser::StandardMember::kMath##FName: { \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
STATIC_CHAR_VECTOR(#fname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
@ -115,7 +108,7 @@ bool IsStdlibMemberValid(Isolate* isolate, Handle<JSReceiver> stdlib,
STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC)
#undef STDLIB_MATH_FUNC
#define STDLIB_MATH_CONST(cname, const_value) \
case wasm::AsmTyper::StandardMember::kMath##cname: { \
case wasm::AsmJsParser::StandardMember::kMath##cname: { \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
STATIC_CHAR_VECTOR(#cname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
@ -125,7 +118,7 @@ bool IsStdlibMemberValid(Isolate* isolate, Handle<JSReceiver> stdlib,
STDLIB_MATH_VALUE_LIST(STDLIB_MATH_CONST)
#undef STDLIB_MATH_CONST
#define STDLIB_ARRAY_TYPE(fname, FName) \
case wasm::AsmTyper::StandardMember::k##FName: { \
case wasm::AsmJsParser::StandardMember::k##FName: { \
*is_typed_array = true; \
if (stdlib.is_null()) { \
return false; \
@ -163,7 +156,6 @@ MaybeHandle<FixedArray> AsmJs::CompileAsmViaWasm(CompilationInfo* info) {
Handle<FixedArray> foreign_globals;
base::ElapsedTimer asm_wasm_timer;
asm_wasm_timer.Start();
wasm::AsmWasmBuilder builder(info);
size_t asm_wasm_zone_start = info->zone()->allocation_size();
{
wasm::AsmJsParser parser(info->isolate(), info->zone(), info->script(),
@ -282,8 +274,8 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
bool stdlib_use_of_typed_array_present = false;
for (int i = 0; i < stdlib_uses->length(); ++i) {
int member_id = Smi::cast(stdlib_uses->get(i))->value();
wasm::AsmTyper::StandardMember member =
static_cast<wasm::AsmTyper::StandardMember>(member_id);
wasm::AsmJsParser::StandardMember member =
static_cast<wasm::AsmJsParser::StandardMember>(member_id);
if (!IsStdlibMemberValid(isolate, stdlib, member,
&stdlib_use_of_typed_array_present)) {
return MaybeHandle<Object>();
@ -321,8 +313,8 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
DCHECK(!thrower.error());
Handle<Object> module_object = maybe_module_object.ToHandleChecked();
Handle<Name> single_function_name(isolate->factory()->InternalizeUtf8String(
wasm::AsmWasmBuilder::single_function_name));
Handle<Name> single_function_name(
isolate->factory()->InternalizeUtf8String(AsmJs::kSingleFunctionName));
MaybeHandle<Object> single_function =
Object::GetProperty(module_object, single_function_name);
if (!single_function.is_null() &&

View File

@ -22,6 +22,10 @@ class AsmJs {
Handle<JSReceiver> stdlib,
Handle<JSReceiver> foreign,
Handle<JSArrayBuffer> memory);
// Special export name used to indicate that the module exports a single
// function instead of a JavaScript object holding multiple functions.
static const char* const kSingleFunctionName;
};
} // namespace internal

View File

@ -9,10 +9,12 @@
#include <algorithm>
#include "src/asmjs/asm-js.h"
#include "src/asmjs/asm-types.h"
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/parsing/scanner.h"
#include "src/wasm/wasm-opcodes.h"
namespace v8 {
@ -562,7 +564,7 @@ void AsmJsParser::ValidateModuleVarNewStdlib(VarInfo* info) {
#define V(name, _junk1, _junk2, _junk3) \
case TOK(name): \
DeclareStdlibFunc(info, VarKind::kSpecial, AsmType::name()); \
stdlib_uses_.insert(AsmTyper::k##name); \
stdlib_uses_.insert(StandardMember::k##name); \
break;
STDLIB_ARRAY_TYPE_LIST(V)
#undef V
@ -585,14 +587,14 @@ void AsmJsParser::ValidateModuleVarStdlib(VarInfo* info) {
case TOK(name): \
DeclareGlobal(info, false, AsmType::Double(), kWasmF64, \
WasmInitExpr(const_value)); \
stdlib_uses_.insert(AsmTyper::kMath##name); \
stdlib_uses_.insert(StandardMember::kMath##name); \
break;
STDLIB_MATH_VALUE_LIST(V)
#undef V
#define V(name, Name, op, sig) \
case TOK(name): \
DeclareStdlibFunc(info, VarKind::kMath##Name, stdlib_##sig##_); \
stdlib_uses_.insert(AsmTyper::kMath##Name); \
stdlib_uses_.insert(StandardMember::kMath##Name); \
break;
STDLIB_MATH_FUNCTION_LIST(V)
#undef V
@ -602,11 +604,11 @@ void AsmJsParser::ValidateModuleVarStdlib(VarInfo* info) {
} else if (Check(TOK(Infinity))) {
DeclareGlobal(info, false, AsmType::Double(), kWasmF64,
WasmInitExpr(std::numeric_limits<double>::infinity()));
stdlib_uses_.insert(AsmTyper::kInfinity);
stdlib_uses_.insert(StandardMember::kInfinity);
} else if (Check(TOK(NaN))) {
DeclareGlobal(info, false, AsmType::Double(), kWasmF64,
WasmInitExpr(std::numeric_limits<double>::quiet_NaN()));
stdlib_uses_.insert(AsmTyper::kNaN);
stdlib_uses_.insert(StandardMember::kNaN);
} else {
FAIL("Invalid member of stdlib");
}
@ -649,8 +651,7 @@ void AsmJsParser::ValidateExport() {
if (info->kind != VarKind::kFunction) {
FAIL("Single function export must be a function");
}
const char* single_function_name = "__single_function__";
info->function_builder->ExportAs(CStrVector(single_function_name));
info->function_builder->ExportAs(CStrVector(AsmJs::kSingleFunctionName));
}
}

View File

@ -9,7 +9,6 @@
#include <vector>
#include "src/asmjs/asm-scanner.h"
#include "src/asmjs/asm-typer.h"
#include "src/asmjs/asm-types.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/zone/zone-containers.h"
@ -29,13 +28,31 @@ namespace wasm {
// scopes (local + module wide).
class AsmJsParser {
public:
// clang-format off
enum StandardMember {
kInfinity,
kNaN,
#define V(_unused1, name, _unused2, _unused3) kMath##name,
STDLIB_MATH_FUNCTION_LIST(V)
#undef V
#define V(name, _unused1) kMath##name,
STDLIB_MATH_VALUE_LIST(V)
#undef V
#define V(name, _unused1, _unused2, _unused3) k##name,
STDLIB_ARRAY_TYPE_LIST(V)
#undef V
};
// clang-format on
typedef std::unordered_set<StandardMember, std::hash<int>> StdlibSet;
explicit AsmJsParser(Isolate* isolate, Zone* zone, Handle<Script> script,
int start, int end);
bool Run();
const char* failure_message() const { return failure_message_; }
int failure_location() const { return failure_location_; }
WasmModuleBuilder* module_builder() { return module_builder_; }
const AsmTyper::StdlibSet* stdlib_uses() const { return &stdlib_uses_; }
const StdlibSet* stdlib_uses() const { return &stdlib_uses_; }
private:
// clang-format off
@ -96,7 +113,7 @@ class AsmJsParser {
WasmFunctionBuilder* current_function_builder_;
AsmType* return_type_;
uintptr_t stack_limit_;
AsmTyper::StdlibSet stdlib_uses_;
StdlibSet stdlib_uses_;
ZoneVector<VarInfo> global_var_info_;
ZoneVector<VarInfo> local_var_info_;

File diff suppressed because it is too large Load Diff

View File

@ -1,403 +0,0 @@
// Copyright 2016 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.
#ifndef SRC_ASMJS_ASM_TYPER_H_
#define SRC_ASMJS_ASM_TYPER_H_
#include <cstdint>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include "src/allocation.h"
#include "src/asmjs/asm-names.h"
#include "src/asmjs/asm-types.h"
#include "src/ast/ast-type-bounds.h"
#include "src/ast/ast-types.h"
#include "src/ast/ast.h"
#include "src/effects.h"
#include "src/messages.h"
#include "src/type-info.h"
#include "src/zone/zone-containers.h"
#include "src/zone/zone.h"
namespace v8 {
namespace internal {
namespace wasm {
class AsmType;
class AsmTyperHarnessBuilder;
class SourceLayoutTracker;
class AsmTyper final {
public:
enum StandardMember {
kHeap = -4,
kFFI = -3,
kStdlib = -2,
kModule = -1,
kNone = 0,
kInfinity,
kNaN,
#define V(_unused1, name, _unused2, _unused3) kMath##name,
STDLIB_MATH_FUNCTION_LIST(V)
#undef V
#define V(name, _unused1) kMath##name,
STDLIB_MATH_VALUE_LIST(V)
#undef V
#define V(name, _unused1, _unused2, _unused3) k##name,
STDLIB_ARRAY_TYPE_LIST(V)
#undef V
};
~AsmTyper() = default;
AsmTyper(Isolate* isolate, Zone* zone, Handle<Script> script,
FunctionLiteral* root);
bool Validate();
// Do asm.js validation in phases (to interleave with conversion to wasm).
bool ValidateBeforeFunctionsPhase();
bool ValidateInnerFunction(FunctionDeclaration* decl);
bool ValidateAfterFunctionsPhase();
void ClearFunctionNodeTypes();
Handle<JSMessageObject> error_message() const { return error_message_; }
const MessageLocation* message_location() const { return &message_location_; }
AsmType* TriggerParsingError();
AsmType* TypeOf(AstNode* node) const;
AsmType* TypeOf(Variable* v) const;
StandardMember VariableAsStandardMember(Variable* var);
// Allow the asm-wasm-builder to trigger failures (for interleaved
// validating).
AsmType* FailWithMessage(const char* text);
typedef std::unordered_set<StandardMember, std::hash<int> > StdlibSet;
StdlibSet StdlibUses() const { return stdlib_uses_; }
// Each FFI import has a usage-site signature associated with it.
struct FFIUseSignature {
Variable* var;
ZoneVector<AsmType*> arg_types_;
AsmType* return_type_;
FFIUseSignature(Variable* v, Zone* zone)
: var(v), arg_types_(zone), return_type_(nullptr) {}
};
const ZoneVector<FFIUseSignature>& FFIUseSignatures() {
return ffi_use_signatures_;
}
private:
friend class v8::internal::wasm::AsmTyperHarnessBuilder;
class VariableInfo : public ZoneObject {
public:
enum Mutability {
kInvalidMutability,
kLocal,
kMutableGlobal,
// *VIOLATION* We support const variables in asm.js, as per the
//
// https://discourse.wicg.io/t/allow-const-global-variables/684
//
// Global const variables are treated as if they were numeric literals,
// and can be used anywhere a literal can be used.
kConstGlobal,
kImmutableGlobal,
};
explicit VariableInfo(AsmType* t) : type_(t) {}
VariableInfo* Clone(Zone* zone) const;
bool IsMutable() const {
return mutability_ == kLocal || mutability_ == kMutableGlobal;
}
bool IsGlobal() const {
return mutability_ == kImmutableGlobal || mutability_ == kConstGlobal ||
mutability_ == kMutableGlobal;
}
bool IsStdlib() const { return standard_member_ == kStdlib; }
bool IsFFI() const { return standard_member_ == kFFI; }
bool IsHeap() const { return standard_member_ == kHeap; }
void MarkDefined() { missing_definition_ = false; }
void SetFirstForwardUse(const MessageLocation& source_location);
StandardMember standard_member() const { return standard_member_; }
void set_standard_member(StandardMember standard_member) {
standard_member_ = standard_member;
}
AsmType* type() const { return type_; }
void set_type(AsmType* type) { type_ = type; }
Mutability mutability() const { return mutability_; }
void set_mutability(Mutability mutability) { mutability_ = mutability; }
bool missing_definition() const { return missing_definition_; }
const MessageLocation* source_location() { return &source_location_; }
static VariableInfo* ForSpecialSymbol(Zone* zone,
StandardMember standard_member);
private:
AsmType* type_;
StandardMember standard_member_ = kNone;
Mutability mutability_ = kInvalidMutability;
// missing_definition_ is set to true for forward definition - i.e., use
// before definition.
bool missing_definition_ = false;
// Used for error messages.
MessageLocation source_location_;
};
// RAII-style manager for the in_function_ member variable.
struct FunctionScope {
explicit FunctionScope(AsmTyper* typer) : typer_(typer) {
DCHECK(!typer_->in_function_);
typer_->in_function_ = true;
typer_->local_scope_.Clear();
typer_->return_type_ = AsmType::None();
}
~FunctionScope() {
DCHECK(typer_->in_function_);
typer_->in_function_ = false;
}
AsmTyper* typer_;
};
// FlattenedStatements is an iterator class for ZoneList<Statement*> that
// flattens the Block construct in the AST. This is here because we need it in
// the tests.
class FlattenedStatements {
public:
explicit FlattenedStatements(Zone* zone, ZoneList<Statement*>* s);
Statement* Next();
private:
struct Context {
explicit Context(ZoneList<Statement*>* s) : statements_(s) {}
ZoneList<Statement*>* statements_;
int next_index_ = 0;
};
ZoneVector<Context> context_stack_;
DISALLOW_IMPLICIT_CONSTRUCTORS(FlattenedStatements);
};
class SourceLayoutTracker {
public:
SourceLayoutTracker() = default;
bool IsValid() const;
void AddUseAsm(const AstNode& node) { use_asm_.AddNewElement(node); }
void AddGlobal(const AstNode& node) { globals_.AddNewElement(node); }
void AddFunction(const AstNode& node) { functions_.AddNewElement(node); }
void AddTable(const AstNode& node) { tables_.AddNewElement(node); }
void AddExport(const AstNode& node) { exports_.AddNewElement(node); }
private:
class Section {
public:
Section() = default;
Section(const Section&) = default;
Section& operator=(const Section&) = default;
void AddNewElement(const AstNode& node);
bool IsPrecededBy(const Section& other) const;
private:
int start_ = kNoSourcePosition;
int end_ = kNoSourcePosition;
};
Section use_asm_;
Section globals_;
Section functions_;
Section tables_;
Section exports_;
DISALLOW_COPY_AND_ASSIGN(SourceLayoutTracker);
};
using ObjectTypeMap = ZoneMap<std::string, VariableInfo*>;
void InitializeStdlib();
void SetTypeOf(AstNode* node, AsmType* type);
void AddForwardReference(VariableProxy* proxy, VariableInfo* info);
bool AddGlobal(Variable* global, VariableInfo* info);
bool AddLocal(Variable* global, VariableInfo* info);
// Used for 5.5 GlobalVariableTypeAnnotations
VariableInfo* ImportLookup(Property* expr);
// 3.3 Environment Lookup
// NOTE: In the spec, the lookup function's prototype is
//
// Lookup(Delta, Gamma, x)
//
// Delta is the global_scope_ member, and Gamma, local_scope_.
VariableInfo* Lookup(Variable* variable) const;
// All of the ValidateXXX methods below return AsmType::None() in case of
// validation failure.
// 6.1 ValidateModule
AsmType* ValidateModuleBeforeFunctionsPhase(FunctionLiteral* fun);
AsmType* ValidateModuleFunction(FunctionDeclaration* fun_decl);
AsmType* ValidateModuleFunctions(FunctionLiteral* fun);
AsmType* ValidateModuleAfterFunctionsPhase(FunctionLiteral* fun);
AsmType* ValidateGlobalDeclaration(Assignment* assign);
// 6.2 ValidateExport
AsmType* ExportType(VariableProxy* fun_export);
AsmType* ValidateExport(ReturnStatement* exports);
// 6.3 ValidateFunctionTable
AsmType* ValidateFunctionTable(Assignment* assign);
// 6.4 ValidateFunction
AsmType* ValidateFunction(FunctionDeclaration* fun_decl);
// 6.5 ValidateStatement
AsmType* ValidateStatement(Statement* statement);
// 6.5.1 BlockStatement
AsmType* ValidateBlockStatement(Block* block);
// 6.5.2 ExpressionStatement
AsmType* ValidateExpressionStatement(ExpressionStatement* expr);
// 6.5.3 EmptyStatement
AsmType* ValidateEmptyStatement(EmptyStatement* empty);
// 6.5.4 IfStatement
AsmType* ValidateIfStatement(IfStatement* if_stmt);
// 6.5.5 ReturnStatement
AsmType* ValidateReturnStatement(ReturnStatement* ret_stmt);
// 6.5.6 IterationStatement
// 6.5.6.a WhileStatement
AsmType* ValidateWhileStatement(WhileStatement* while_stmt);
// 6.5.6.b DoWhileStatement
AsmType* ValidateDoWhileStatement(DoWhileStatement* do_while);
// 6.5.6.c ForStatement
AsmType* ValidateForStatement(ForStatement* for_stmt);
// 6.5.7 BreakStatement
AsmType* ValidateBreakStatement(BreakStatement* brk_stmt);
// 6.5.8 ContinueStatement
AsmType* ValidateContinueStatement(ContinueStatement* cont_stmt);
// 6.5.9 LabelledStatement
// NOTE: we don't need to handle these: Labelled statements are
// BreakableStatements in our AST, but BreakableStatement is not a concrete
// class -- and we're handling all of BreakableStatement's subclasses.
// 6.5.10 SwitchStatement
AsmType* ValidateSwitchStatement(SwitchStatement* stmt);
// 6.6 ValidateCase
AsmType* ValidateCase(CaseClause* label, int32_t* case_lbl);
// 6.7 ValidateDefault
AsmType* ValidateDefault(CaseClause* label);
// 6.8 ValidateExpression
AsmType* ValidateExpression(Expression* expr);
AsmType* ValidateCompareOperation(CompareOperation* cmp);
AsmType* ValidateBinaryOperation(BinaryOperation* binop);
// 6.8.1 Expression
AsmType* ValidateCommaExpression(BinaryOperation* comma);
// 6.8.2 NumericLiteral
AsmType* ValidateNumericLiteral(Literal* literal);
// 6.8.3 Identifier
AsmType* ValidateIdentifier(VariableProxy* proxy);
// 6.8.4 CallExpression
AsmType* ValidateCallExpression(Call* call);
// 6.8.5 MemberExpression
AsmType* ValidateMemberExpression(Property* prop);
// 6.8.6 AssignmentExpression
AsmType* ValidateAssignmentExpression(Assignment* assignment);
// 6.8.7 UnaryExpression
AsmType* ValidateUnaryExpression(UnaryOperation* unop);
// 6.8.8 MultiplicativeExpression
AsmType* ValidateMultiplicativeExpression(BinaryOperation* binop);
// 6.8.9 AdditiveExpression
AsmType* ValidateAdditiveExpression(BinaryOperation* binop,
uint32_t intish_count);
// 6.8.10 ShiftExpression
AsmType* ValidateShiftExpression(BinaryOperation* binop);
// 6.8.11 RelationalExpression
AsmType* ValidateRelationalExpression(CompareOperation* cmpop);
// 6.8.12 EqualityExpression
AsmType* ValidateEqualityExpression(CompareOperation* cmpop);
// 6.8.13 BitwiseANDExpression
AsmType* ValidateBitwiseANDExpression(BinaryOperation* binop);
// 6.8.14 BitwiseXORExpression
AsmType* ValidateBitwiseXORExpression(BinaryOperation* binop);
// 6.8.15 BitwiseORExpression
AsmType* ValidateBitwiseORExpression(BinaryOperation* binop);
// 6.8.16 ConditionalExpression
AsmType* ValidateConditionalExpression(Conditional* cond);
// 6.9 ValidateCall
AsmType* ValidateCall(AsmType* return_type, Call* call);
// 6.10 ValidateHeapAccess
enum HeapAccessType { LoadFromHeap, StoreToHeap };
AsmType* ValidateHeapAccess(Property* heap, HeapAccessType access_type);
// 6.11 ValidateFloatCoercion
bool IsCallToFround(Call* call);
AsmType* ValidateFloatCoercion(Call* call);
// 5.1 ParameterTypeAnnotations
AsmType* ParameterTypeAnnotations(Variable* parameter,
Expression* annotation);
// 5.2 ReturnTypeAnnotations
AsmType* ReturnTypeAnnotations(Expression* ret_expr);
// 5.4 VariableTypeAnnotations
// 5.5 GlobalVariableTypeAnnotations
AsmType* VariableTypeAnnotations(
Expression* initializer,
VariableInfo::Mutability global = VariableInfo::kLocal);
AsmType* ImportExpression(Property* import);
AsmType* NewHeapView(CallNew* new_heap_view);
Isolate* isolate_;
Zone* zone_;
Handle<Script> script_;
FunctionLiteral* root_;
bool in_function_ = false;
AsmType* return_type_ = nullptr;
ZoneVector<VariableInfo*> forward_definitions_;
ZoneVector<FFIUseSignature> ffi_use_signatures_;
ObjectTypeMap stdlib_types_;
ObjectTypeMap stdlib_math_types_;
// The ASM module name. This member is used to prevent globals from redefining
// the module name.
VariableInfo* module_info_;
Handle<String> module_name_;
// 3 Environments
ZoneHashMap global_scope_; // 3.1 Global environment
ZoneHashMap local_scope_; // 3.2 Variable environment
std::uintptr_t stack_limit_;
bool stack_overflow_ = false;
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_;
Handle<JSMessageObject> error_message_;
MessageLocation message_location_;
StdlibSet stdlib_uses_;
SourceLayoutTracker source_layout_;
ReturnStatement* module_return_;
ZoneVector<Assignment*> function_pointer_tables_;
DISALLOW_IMPLICIT_CONSTRUCTORS(AsmTyper);
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // SRC_ASMJS_ASM_TYPER_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
// Copyright 2015 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.
#ifndef V8_ASMJS_ASM_WASM_BUILDER_H_
#define V8_ASMJS_ASM_WASM_BUILDER_H_
#include "src/allocation.h"
#include "src/asmjs/asm-typer.h"
#include "src/objects.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/zone/zone.h"
namespace v8 {
namespace internal {
class CompilationInfo;
namespace wasm {
class AsmWasmBuilder {
public:
struct Result {
ZoneBuffer* module_bytes;
ZoneBuffer* asm_offset_table;
bool success;
};
explicit AsmWasmBuilder(CompilationInfo* info);
Result Run(Handle<FixedArray>* foreign_args);
static const char* foreign_init_name;
static const char* single_function_name;
const AsmTyper* typer() { return &typer_; }
private:
CompilationInfo* info_;
AsmTyper typer_;
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // V8_WASM_ASM_WASM_BUILDER_H_

View File

@ -8,7 +8,6 @@
#include <memory>
#include "src/asmjs/asm-js.h"
#include "src/asmjs/asm-typer.h"
#include "src/assembler-inl.h"
#include "src/ast/ast-numbering.h"
#include "src/ast/prettyprinter.h"

View File

@ -418,12 +418,8 @@
'asmjs/asm-parser.h',
'asmjs/asm-scanner.cc',
'asmjs/asm-scanner.h',
'asmjs/asm-typer.cc',
'asmjs/asm-typer.h',
'asmjs/asm-types.cc',
'asmjs/asm-types.h',
'asmjs/asm-wasm-builder.cc',
'asmjs/asm-wasm-builder.h',
'asmjs/switch-logic.h',
'asmjs/switch-logic.cc',
'assembler.cc',

View File

@ -4,9 +4,6 @@
#include "src/api-natives.h"
#include "src/api.h"
#include "src/asmjs/asm-js.h"
#include "src/asmjs/asm-typer.h"
#include "src/asmjs/asm-wasm-builder.h"
#include "src/assert-scope.h"
#include "src/ast/ast.h"
#include "src/execution.h"

View File

@ -4,6 +4,7 @@
#include <memory>
#include "src/asmjs/asm-js.h"
#include "src/assembler-inl.h"
#include "src/base/atomic-utils.h"
#include "src/code-stubs.h"
@ -17,7 +18,6 @@
#include "src/trap-handler/trap-handler.h"
#include "src/v8.h"
#include "src/asmjs/asm-wasm-builder.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-code-specialization.h"
@ -1858,12 +1858,8 @@ class InstantiationHelper {
isolate_->factory()->InternalizeUtf8String("exports");
JSObject::AddProperty(instance, exports_name, exports_object, NONE);
Handle<String> foreign_init_name =
isolate_->factory()->InternalizeUtf8String(
wasm::AsmWasmBuilder::foreign_init_name);
Handle<String> single_function_name =
isolate_->factory()->InternalizeUtf8String(
wasm::AsmWasmBuilder::single_function_name);
isolate_->factory()->InternalizeUtf8String(AsmJs::kSingleFunctionName);
PropertyDescriptor desc;
desc.set_writable(module_->is_asm_js());
@ -1893,8 +1889,7 @@ class InstantiationHelper {
.ToHandleChecked();
Handle<JSObject> export_to;
if (module_->is_asm_js() && exp.kind == kExternalFunction &&
(String::Equals(name, foreign_init_name) ||
String::Equals(name, single_function_name))) {
String::Equals(name, single_function_name)) {
export_to = instance;
} else {
export_to = exports_object;

View File

@ -13,7 +13,6 @@ v8_executable("cctest") {
### gcmole(all) ###
"../common/wasm/test-signatures.h",
"../common/wasm/wasm-macro-gen.h",
"asmjs/test-asm-typer.cc",
"ast-types-fuzz.h",
"cctest.cc",
"cctest.h",

View File

@ -1,10 +0,0 @@
# Keep in sync with src/asmjs/OWNERS.
set noparent
ahaas@chromium.org
bradnelson@chromium.org
clemensh@chromium.org
mtrofin@chromium.org
rossberg@chromium.org
titzer@chromium.org

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,6 @@
'v8_code': 1,
'generated_file': '<(SHARED_INTERMEDIATE_DIR)/resources.cc',
'cctest_sources': [ ### gcmole(all) ###
'asmjs/test-asm-typer.cc',
'ast-types-fuzz.h',
'compiler/c-signature.h',
'compiler/call-tester.h',