Commit b0711ccc authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm] Drop old typing-asm and its tests.

BUG= https://bugs.chromium.org/p/v8/issues/detail?id=4203
TEST= cctest/asmjs/test-asm-typer
LOG=N
R=jpp@chromium.org

Review-Url: https://codereview.chromium.org/2146853004
Cr-Commit-Position: refs/heads/master@{#37734}
parent 304572c9
......@@ -794,8 +794,6 @@ v8_source_set("v8_base") {
"src/asmjs/asm-types.h",
"src/asmjs/asm-wasm-builder.cc",
"src/asmjs/asm-wasm-builder.h",
"src/asmjs/typing-asm.cc",
"src/asmjs/typing-asm.h",
"src/assembler.cc",
"src/assembler.h",
"src/assert-scope.cc",
......
This diff is collapsed.
// 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_TYPING_ASM_H_
#define V8_ASMJS_TYPING_ASM_H_
#include "src/allocation.h"
#include "src/ast/ast-type-bounds.h"
#include "src/ast/ast.h"
#include "src/effects.h"
#include "src/type-info.h"
#include "src/types.h"
#include "src/zone.h"
namespace v8 {
namespace internal {
class TypeCache;
class AsmTyper : public AstVisitor {
public:
explicit AsmTyper(Isolate* isolate, Zone* zone, Script* script,
FunctionLiteral* root);
bool Validate();
void set_allow_simd(bool simd) { allow_simd_ = simd; }
void set_fixed_signature(bool fixed) { fixed_signature_ = fixed; }
const char* error_message() { return error_message_; }
const AstTypeBounds* bounds() { return &bounds_; }
enum StandardMember {
kNone = 0,
kStdlib,
kInfinity,
kNaN,
kMathAcos,
kMathAsin,
kMathAtan,
kMathCos,
kMathSin,
kMathTan,
kMathExp,
kMathLog,
kMathCeil,
kMathFloor,
kMathSqrt,
kMathAbs,
kMathMin,
kMathMax,
kMathAtan2,
kMathPow,
kMathImul,
kMathFround,
kMathE,
kMathLN10,
kMathLN2,
kMathLOG2E,
kMathLOG10E,
kMathPI,
kMathSQRT1_2,
kMathSQRT2,
};
StandardMember VariableAsStandardMember(Variable* variable);
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
private:
Zone* zone_;
Isolate* isolate_;
Script* script_;
FunctionLiteral* root_;
bool valid_;
bool allow_simd_;
bool fixed_signature_;
struct VariableInfo : public ZoneObject {
Type* type;
bool is_check_function;
bool is_constructor_function;
StandardMember standard_member;
VariableInfo()
: type(NULL),
is_check_function(false),
is_constructor_function(false),
standard_member(kNone) {}
explicit VariableInfo(Type* t)
: type(t),
is_check_function(false),
is_constructor_function(false),
standard_member(kNone) {}
};
// Information for bi-directional typing with a cap on nesting depth.
Type* expected_type_;
Type* computed_type_;
VariableInfo* property_info_;
int32_t intish_; // How many ops we've gone without a x|0.
Type* return_type_; // Return type of last function.
size_t array_size_; // Array size of last ArrayLiteral.
typedef ZoneMap<std::string, VariableInfo*> ObjectTypeMap;
ObjectTypeMap stdlib_types_;
ObjectTypeMap stdlib_heap_types_;
ObjectTypeMap stdlib_math_types_;
#define V(NAME, Name, name, lane_count, lane_type) \
ObjectTypeMap stdlib_simd_##name##_types_; \
VariableInfo* stdlib_simd_##name##_constructor_type_;
SIMD128_TYPES(V)
#undef V
// Map from Variable* to global/local variable Type*.
ZoneHashMap global_variable_type_;
ZoneHashMap local_variable_type_;
bool in_function_; // In module function?
bool building_function_tables_;
bool visiting_exports_;
TypeCache const& cache_;
AstTypeBounds bounds_;
static const int kErrorMessageLimit = 150;
char error_message_[kErrorMessageLimit];
static const int kMaxUncombinedAdditiveSteps = 1 << 20;
static const int kMaxUncombinedMultiplicativeSteps = 1;
void InitializeStdlib();
void InitializeStdlibSIMD();
void VisitDeclarations(ZoneList<Declaration*>* d) override;
void VisitStatements(ZoneList<Statement*>* s) override;
void VisitExpressionAnnotation(Expression* e, Variable* var, bool is_return);
void VisitFunctionAnnotation(FunctionLiteral* f);
void VisitAsmModule(FunctionLiteral* f);
void VisitHeapAccess(Property* expr, bool assigning, Type* assignment_type);
void CheckPolymorphicStdlibArguments(enum StandardMember standard_member,
ZoneList<Expression*>* args);
Expression* GetReceiverOfPropertyAccess(Expression* expr, const char* name);
bool IsMathObject(Expression* expr);
bool IsSIMDObject(Expression* expr);
bool IsSIMDTypeObject(Expression* expr, const char* name);
bool IsStdlibObject(Expression* expr);
void VisitSIMDProperty(Property* expr);
int ElementShiftSize(Type* type);
Type* StorageType(Type* type);
void SetType(Variable* variable, Type* type);
Type* GetType(Variable* variable);
VariableInfo* GetVariableInfo(Variable* variable);
VariableInfo* MakeVariableInfo(Variable* variable);
void SetVariableInfo(Variable* variable, const VariableInfo* info);
VariableInfo* LibType(ObjectTypeMap* map, Handle<String> name);
void VisitLibraryAccess(ObjectTypeMap* map, Property* expr);
void SetResult(Expression* expr, Type* type);
void IntersectResult(Expression* expr, Type* type);
void VisitWithExpectation(Expression* expr, Type* expected_type,
const char* msg);
void VisitLiteral(Literal* expr, bool is_return);
void VisitIntegerBitwiseOperator(BinaryOperation* expr, Type* left_expected,
Type* right_expected, Type* result_type,
bool conversion);
Zone* zone() const { return zone_; }
#define DECLARE_VISIT(type) void Visit##type(type* node) override;
AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
DISALLOW_COPY_AND_ASSIGN(AsmTyper);
};
} // namespace internal
} // namespace v8
#endif // V8_TYPING_ASM_H_
......@@ -7,7 +7,7 @@
#include <algorithm>
#include "src/asmjs/asm-js.h"
#include "src/asmjs/typing-asm.h"
#include "src/asmjs/asm-typer.h"
#include "src/ast/ast-numbering.h"
#include "src/ast/prettyprinter.h"
#include "src/ast/scopeinfo.h"
......
......@@ -426,8 +426,6 @@
'asmjs/asm-types.h',
'asmjs/asm-wasm-builder.cc',
'asmjs/asm-wasm-builder.h',
'asmjs/typing-asm.cc',
'asmjs/typing-asm.h',
'assembler.cc',
'assembler.h',
'assert-scope.h',
......
......@@ -4,8 +4,8 @@
#include "src/api-natives.h"
#include "src/api.h"
#include "src/asmjs/asm-typer.h"
#include "src/asmjs/asm-wasm-builder.h"
#include "src/asmjs/typing-asm.h"
#include "src/assert-scope.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
......
......@@ -16,5 +16,3 @@ per-file *-s390*=mbrandy@us.ibm.com
per-file *-s390*=michael_dawson@ca.ibm.com
per-file *-x87*=chunyang.dai@intel.com
per-file *-x87*=weiliang.lin@intel.com
per-file expression-type-collector*=aseemgarg@chromium.org
per-file expression-type-collector*=bradnelson@chromium.org
This diff is collapsed.
......@@ -33,7 +33,6 @@
'generated_file': '<(SHARED_INTERMEDIATE_DIR)/resources.cc',
'cctest_sources': [ ### gcmole(all) ###
'asmjs/test-asm-typer.cc',
'asmjs/test-typing-asm.cc',
'compiler/c-signature.h',
'compiler/codegen-tester.cc',
'compiler/codegen-tester.h',
......@@ -78,8 +77,6 @@
'compiler/test-run-wasm-machops.cc',
'compiler/test-simplified-lowering.cc',
'cctest.cc',
'expression-type-collector.cc',
'expression-type-collector.h',
'interpreter/interpreter-tester.cc',
'interpreter/source-position-matcher.cc',
'interpreter/source-position-matcher.h',
......@@ -116,7 +113,6 @@
'test-api-fast-accessor-builder.cc',
'test-array-list.cc',
'test-ast.cc',
'test-ast-expression-visitor.cc',
'test-atomicops.cc',
'test-bignum.cc',
'test-bignum-dtoa.cc',
......
// 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.
#include "src/v8.h"
#include "test/cctest/expression-type-collector.h"
#include "src/ast/ast-type-bounds.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/codegen.h"
namespace v8 {
namespace internal {
namespace {
struct {
AstNode::NodeType type;
const char* name;
} NodeTypeNameList[] = {
#define DECLARE_VISIT(type) \
{ AstNode::k##type, #type } \
,
AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
};
} // namespace
ExpressionTypeCollector::ExpressionTypeCollector(
Isolate* isolate, FunctionLiteral* root, const AstTypeBounds* bounds,
ZoneVector<ExpressionTypeEntry>* dst)
: AstExpressionVisitor(isolate, root), bounds_(bounds), result_(dst) {}
void ExpressionTypeCollector::Run() {
result_->clear();
AstExpressionVisitor::Run();
}
void ExpressionTypeCollector::VisitExpression(Expression* expression) {
ExpressionTypeEntry e;
e.depth = depth();
VariableProxy* proxy = expression->AsVariableProxy();
if (proxy) {
e.name = proxy->raw_name();
}
e.bounds = bounds_->get(expression);
AstNode::NodeType type = expression->node_type();
e.kind = "unknown";
for (size_t i = 0; i < arraysize(NodeTypeNameList); ++i) {
if (NodeTypeNameList[i].type == type) {
e.kind = NodeTypeNameList[i].name;
break;
}
}
result_->push_back(e);
}
} // namespace internal
} // namespace v8
// 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_EXPRESSION_TYPE_COLLECTOR_H_
#define V8_EXPRESSION_TYPE_COLLECTOR_H_
#include "src/ast/ast-expression-visitor.h"
namespace v8 {
namespace internal {
class AstTypeBounds;
// A Visitor over an AST that collects a human readable string summarizing
// structure and types. Used for testing of the typing information attached
// to the expression nodes of an AST.
struct ExpressionTypeEntry {
int depth;
const char* kind;
const AstRawString* name;
Bounds bounds;
};
class ExpressionTypeCollector : public AstExpressionVisitor {
public:
ExpressionTypeCollector(Isolate* isolate, FunctionLiteral* root,
const AstTypeBounds* bounds,
ZoneVector<ExpressionTypeEntry>* dst);
void Run();
protected:
void VisitExpression(Expression* expression);
private:
const AstTypeBounds* bounds_;
ZoneVector<ExpressionTypeEntry>* result_;
};
} // namespace internal
} // namespace v8
#endif // V8_EXPRESSION_TYPE_COLLECTOR_H_
// 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.
#include <stdlib.h>
#include <map>
#include "src/v8.h"
#include "src/ast/ast.h"
#include "src/ast/ast-expression-visitor.h"
#include "src/ast/scopes.h"
#include "src/parsing/parser.h"
#include "src/parsing/rewriter.h"
#include "test/cctest/cctest.h"
#include "test/cctest/expression-type-collector.h"
#include "test/cctest/expression-type-collector-macros.h"
using namespace v8::internal;
namespace {
class NodeTypeCounter : public AstExpressionVisitor {
public:
typedef std::map<AstNode::NodeType, int> Counters;
NodeTypeCounter(Isolate* isolate, Expression* expr, Counters* counts)
: AstExpressionVisitor(isolate, expr), counts_(counts) {}
protected:
void VisitExpression(Expression* expr) override {
(*counts_)[expr->node_type()]++;
}
private:
Counters* counts_;
};
} // namespace
TEST(VisitExpression) {
const char test_function[] =
"function GeometricMean(stdlib, foreign, buffer) {\n"
" \"use asm\";\n"
"\n"
" var exp = stdlib.Math.exp;\n"
" var log = stdlib.Math.log;\n"
" var values = new stdlib.Float64Array(buffer);\n"
"\n"
" function logSum(start, end) {\n"
" start = start|0;\n"
" end = end|0;\n"
"\n"
" var sum = 0.0, p = 0, q = 0;\n"
"\n"
" // asm.js forces byte addressing of the heap by requiring shifting "
"by 3\n"
" for (p = start << 3, q = end << 3; (p|0) < (q|0); p = (p + 8)|0) {\n"
" sum = sum + +log(values[p>>3]);\n"
" }\n"
"\n"
" return +sum;\n"
" }\n"
"\n"
" function geometricMean(start, end) {\n"
" start = start|0;\n"
" end = end|0;\n"
"\n"
" return +exp(+logSum(start, end) / +((end - start)|0));\n"
" }\n"
"\n"
" return { geometricMean: geometricMean };\n"
"}\n";
// Parse + compile test_function, and extract the AST node for it.
v8::V8::Initialize();
HandleAndZoneScope handles;
i::Isolate* isolate = CcTest::i_isolate();
i::Handle<i::String> source_code =
isolate->factory()
->NewStringFromUtf8(i::CStrVector(test_function))
.ToHandleChecked();
i::Handle<i::Script> script = isolate->factory()->NewScript(source_code);
i::ParseInfo info(handles.main_zone(), script);
i::Parser parser(&info);
info.set_global();
info.set_lazy(false);
info.set_allow_lazy_parsing(false);
info.set_toplevel(true);
CHECK(i::Compiler::ParseAndAnalyze(&info));
Expression* test_function_expr =
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun();
// Run NodeTypeCounter and sanity check counts for 3 expression types,
// and for overall # of types found.
NodeTypeCounter::Counters counts;
NodeTypeCounter(isolate, test_function_expr, &counts).Run();
CHECK_EQ(21, counts[AstNode::kBinaryOperation]);
CHECK_EQ(26, counts[AstNode::kLiteral]);
CHECK_EQ(3, counts[AstNode::kFunctionLiteral]);
CHECK_EQ(10, counts.size());
}
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