Reviewers: rossberg, titzer,
Description:
Refactor type collector testing macros.
Assume a zone is in scope instead of a handles object.
Move INT32_TYPE into test-typing-reset.
Provide a CHECK_SKIP() macro to allow skipping
sections of an ast expression walk.
BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=test-typing-reset, test-ast-expression-visitor
[email protected],[email protected]
LOG=N
Please review this at https://codereview.chromium.org/1319983004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+56, -20 lines):
M test/cctest/expression-type-collector-macros.h
M test/cctest/test-ast-expression-visitor.cc
M test/cctest/test-typing-reset.cc
Index: test/cctest/expression-type-collector-macros.h
diff --git a/test/cctest/expression-type-collector-macros.h
b/test/cctest/expression-type-collector-macros.h
index
2dcc1dcae73ca67332ecf789ea9487aff7b4d371..7071717b9a1631ead825e074f2b2450b2009b893
100644
--- a/test/cctest/expression-type-collector-macros.h
+++ b/test/cctest/expression-type-collector-macros.h
@@ -14,17 +14,14 @@
CHECK_EQ(index, types.size()); \
}
-#define DEFAULT_TYPE Bounds::Unbounded(handles.main_zone())
-#define INT32_TYPE \
- Bounds(Type::Signed32(handles.main_zone()), \
- Type::Signed32(handles.main_zone()))
-
-#define CHECK_EXPR(ekind, type) \
- CHECK_LT(index, types.size()); \
- CHECK(strcmp(#ekind, types[index].kind) == 0); \
- CHECK_EQ(depth, types[index].depth); \
- CHECK(type.lower->Is(types[index].bounds.lower)); \
- CHECK(type.upper->Is(types[index].bounds.upper)); \
+#define DEFAULT_TYPE Bounds::Unbounded(zone)
+
+
+#define CHECK_EXPR(ekind, type) \
+ CHECK_LT(index, types.size()); \
+ CHECK(strcmp(#ekind, types[index].kind) == 0); \
+ CHECK_EQ(depth, types[index].depth); \
+ CHECK(types[index].bounds.Narrows(type)); \
for (int j = (++depth, ++index, 0); j < 1 ? 1 : (--depth, 0); ++j)
#define CHECK_VAR(vname, type) \
@@ -33,4 +30,12 @@
types[index - 1].name->raw_data() + \
types[index - 1].name->byte_length()));
+#define CHECK_SKIP() \
+ { \
+ ++index; \
+ while (index < types.size() && types[index].depth > depth) { \
+ ++index; \
+ } \
+ }
+
#endif // V8_EXPRESSION_TYPE_COLLECTOR_MACROS_H_
Index: test/cctest/test-ast-expression-visitor.cc
diff --git a/test/cctest/test-ast-expression-visitor.cc
b/test/cctest/test-ast-expression-visitor.cc
index
f4c1028ab2b16c932820a4a609c6b06c53373cf9..448552c914d717e2b1469b7a99c98c89dce2b737
100644
--- a/test/cctest/test-ast-expression-visitor.cc
+++ b/test/cctest/test-ast-expression-visitor.cc
@@ -51,7 +51,8 @@ static void CollectTypes(HandleAndZoneScope* handles,
const char* source,
TEST(VisitExpressions) {
v8::V8::Initialize();
HandleAndZoneScope handles;
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
const char test_function[] =
"function GeometricMean(stdlib, foreign, buffer) {\n"
" \"use asm\";\n"
@@ -273,7 +274,8 @@ TEST(VisitExpressions) {
TEST(VisitEmptyForStatment) {
v8::V8::Initialize();
HandleAndZoneScope handles;
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
// Check that traversing an empty for statement works.
const char test_function[] =
"function foo() {\n"
@@ -290,7 +292,8 @@ TEST(VisitEmptyForStatment) {
TEST(VisitSwitchStatment) {
v8::V8::Initialize();
HandleAndZoneScope handles;
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
// Check that traversing a switch with a default works.
const char test_function[] =
"function foo() {\n"
@@ -315,7 +318,8 @@ TEST(VisitSwitchStatment) {
TEST(VisitThrow) {
v8::V8::Initialize();
HandleAndZoneScope handles;
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
// Check that traversing an empty for statement works.
const char test_function[] =
"function foo() {\n"
@@ -334,7 +338,8 @@ TEST(VisitThrow) {
TEST(VisitYield) {
v8::V8::Initialize();
HandleAndZoneScope handles;
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
// Check that traversing an empty for statement works.
const char test_function[] =
"function* foo() {\n"
@@ -365,3 +370,27 @@ TEST(VisitYield) {
}
CHECK_TYPES_END
}
+
+
+TEST(VisitSkipping) {
+ v8::V8::Initialize();
+ HandleAndZoneScope handles;
+ Zone* zone = handles.main_zone();
+ ZoneVector<ExpressionTypeEntry> types(zone);
+ // Check that traversing an empty for statement works.
+ const char test_function[] =
+ "function foo(x) {\n"
+ " return (x + x) + 1;\n"
+ "}\n";
+ CollectTypes(&handles, test_function, &types);
+ CHECK_TYPES_BEGIN {
+ CHECK_EXPR(FunctionLiteral, DEFAULT_TYPE) {
+ CHECK_EXPR(BinaryOperation, DEFAULT_TYPE) {
+ // Skip x + x
+ CHECK_SKIP();
+ CHECK_EXPR(Literal, DEFAULT_TYPE);
+ }
+ }
+ }
+ CHECK_TYPES_END
+}
Index: test/cctest/test-typing-reset.cc
diff --git a/test/cctest/test-typing-reset.cc
b/test/cctest/test-typing-reset.cc
index
1dc701b55439f33897d8fde65efe70f76f150b82..55a368f25e646efecdc408cabc25509bb6bf8a6a
100644
--- a/test/cctest/test-typing-reset.cc
+++ b/test/cctest/test-typing-reset.cc
@@ -17,6 +17,8 @@
#include "test/cctest/expression-type-collector.h"
#include "test/cctest/expression-type-collector-macros.h"
+#define INT32_TYPE Bounds(Type::Signed32(), Type::Signed32())
+
using namespace v8::internal;
namespace {
@@ -27,14 +29,13 @@ class TypeSetter : public AstExpressionVisitor {
protected:
void VisitExpression(Expression* expression) {
- expression->set_bounds(Bounds(Type::Integral32()));
+ expression->set_bounds(INT32_TYPE);
}
};
void CheckAllSame(ZoneVector<ExpressionTypeEntry>& types,
Bounds expected_type) {
- HandleAndZoneScope handles;
CHECK_TYPES_BEGIN {
// function logSum
CHECK_EXPR(FunctionLiteral, expected_type) {
@@ -256,6 +257,7 @@ TEST(ResetTypingInfo) {
v8::V8::Initialize();
HandleAndZoneScope handles;
+ Zone* zone = handles.main_zone();
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
@@ -266,7 +268,7 @@ TEST(ResetTypingInfo) {
i::Handle<i::Script> script = factory->NewScript(source_code);
- i::ParseInfo info(handles.main_zone(), script);
+ i::ParseInfo info(zone, script);
i::Parser parser(&info);
parser.set_allow_harmony_arrow_functions(true);
parser.set_allow_harmony_sloppy(true);
@@ -281,7 +283,7 @@ TEST(ResetTypingInfo) {
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
// Core of the test.
- ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
+ ZoneVector<ExpressionTypeEntry> types(zone);
ExpressionTypeCollector(&compilation_info, &types).Run();
CheckAllSame(types, DEFAULT_TYPE);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.