| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-expression-visitor.h" | 8 #include "src/ast-expression-visitor.h" |
| 9 #include "src/parser.h" | 9 #include "src/parser.h" |
| 10 #include "src/rewriter.h" | 10 #include "src/rewriter.h" |
| 11 #include "src/scopes.h" | 11 #include "src/scopes.h" |
| 12 #include "src/type-cache.h" |
| 12 #include "src/typing-asm.h" | 13 #include "src/typing-asm.h" |
| 13 #include "src/zone-type-cache.h" | |
| 14 #include "test/cctest/cctest.h" | 14 #include "test/cctest/cctest.h" |
| 15 #include "test/cctest/expression-type-collector.h" | 15 #include "test/cctest/expression-type-collector.h" |
| 16 #include "test/cctest/expression-type-collector-macros.h" | 16 #include "test/cctest/expression-type-collector-macros.h" |
| 17 | 17 |
| 18 // Macros for function types. | 18 // Macros for function types. |
| 19 #define FUNC_V_TYPE Bounds(Type::Function(Type::Undefined(), zone)) | 19 #define FUNC_V_TYPE Bounds(Type::Function(Type::Undefined(), zone)) |
| 20 #define FUNC_I_TYPE Bounds(Type::Function(cache.kInt32, zone)) | 20 #define FUNC_I_TYPE Bounds(Type::Function(cache.kInt32, zone)) |
| 21 #define FUNC_F_TYPE Bounds(Type::Function(cache.kFloat32, zone)) | 21 #define FUNC_F_TYPE Bounds(Type::Function(cache.kFloat32, zone)) |
| 22 #define FUNC_D_TYPE Bounds(Type::Function(cache.kFloat64, zone)) | 22 #define FUNC_D_TYPE Bounds(Type::Function(cache.kFloat64, zone)) |
| 23 #define FUNC_D2D_TYPE \ | 23 #define FUNC_D2D_TYPE \ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 " }\n" | 109 " }\n" |
| 110 "\n" | 110 "\n" |
| 111 " return { geometricMean: geometricMean };\n" | 111 " return { geometricMean: geometricMean };\n" |
| 112 "}\n"; | 112 "}\n"; |
| 113 | 113 |
| 114 v8::V8::Initialize(); | 114 v8::V8::Initialize(); |
| 115 HandleAndZoneScope handles; | 115 HandleAndZoneScope handles; |
| 116 Zone* zone = handles.main_zone(); | 116 Zone* zone = handles.main_zone(); |
| 117 ZoneVector<ExpressionTypeEntry> types(zone); | 117 ZoneVector<ExpressionTypeEntry> types(zone); |
| 118 CHECK_EQ("", Validate(zone, test_function, &types)); | 118 CHECK_EQ("", Validate(zone, test_function, &types)); |
| 119 ZoneTypeCache cache; | 119 TypeCache cache; |
| 120 | 120 |
| 121 CHECK_TYPES_BEGIN { | 121 CHECK_TYPES_BEGIN { |
| 122 // Module. | 122 // Module. |
| 123 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 123 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
| 124 // function logSum | 124 // function logSum |
| 125 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { | 125 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { |
| 126 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { | 126 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 127 CHECK_VAR(start, Bounds(cache.kInt32)); | 127 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 128 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { | 128 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 129 CHECK_VAR(start, Bounds(cache.kInt32)); | 129 CHECK_VAR(start, Bounds(cache.kInt32)); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 CHECK_EXPR(Literal, Bounds::Unbounded()); \ | 388 CHECK_EXPR(Literal, Bounds::Unbounded()); \ |
| 389 } \ | 389 } \ |
| 390 CHECK_VAR(buffer, Bounds::Unbounded()); \ | 390 CHECK_VAR(buffer, Bounds::Unbounded()); \ |
| 391 } \ | 391 } \ |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 namespace { | 395 namespace { |
| 396 | 396 |
| 397 void CheckStdlibShortcuts(Zone* zone, ZoneVector<ExpressionTypeEntry>& types, | 397 void CheckStdlibShortcuts(Zone* zone, ZoneVector<ExpressionTypeEntry>& types, |
| 398 size_t& index, int& depth, ZoneTypeCache& cache) { | 398 size_t& index, int& depth, TypeCache& cache) { |
| 399 // var exp = stdlib.*; (D * 12) | 399 // var exp = stdlib.*; (D * 12) |
| 400 CHECK_VAR_SHORTCUT(Infinity, Bounds(cache.kFloat64)); | 400 CHECK_VAR_SHORTCUT(Infinity, Bounds(cache.kFloat64)); |
| 401 CHECK_VAR_SHORTCUT(NaN, Bounds(cache.kFloat64)); | 401 CHECK_VAR_SHORTCUT(NaN, Bounds(cache.kFloat64)); |
| 402 // var x = stdlib.Math.x; D2D | 402 // var x = stdlib.Math.x; D2D |
| 403 CHECK_VAR_MATH_SHORTCUT(acos, FUNC_D2D_TYPE); | 403 CHECK_VAR_MATH_SHORTCUT(acos, FUNC_D2D_TYPE); |
| 404 CHECK_VAR_MATH_SHORTCUT(asin, FUNC_D2D_TYPE); | 404 CHECK_VAR_MATH_SHORTCUT(asin, FUNC_D2D_TYPE); |
| 405 CHECK_VAR_MATH_SHORTCUT(atan, FUNC_D2D_TYPE); | 405 CHECK_VAR_MATH_SHORTCUT(atan, FUNC_D2D_TYPE); |
| 406 CHECK_VAR_MATH_SHORTCUT(cos, FUNC_D2D_TYPE); | 406 CHECK_VAR_MATH_SHORTCUT(cos, FUNC_D2D_TYPE); |
| 407 CHECK_VAR_MATH_SHORTCUT(sin, FUNC_D2D_TYPE); | 407 CHECK_VAR_MATH_SHORTCUT(sin, FUNC_D2D_TYPE); |
| 408 CHECK_VAR_MATH_SHORTCUT(tan, FUNC_D2D_TYPE); | 408 CHECK_VAR_MATH_SHORTCUT(tan, FUNC_D2D_TYPE); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 #define CHECK_FUNC_TYPES_BEGIN(func) \ | 446 #define CHECK_FUNC_TYPES_BEGIN(func) \ |
| 447 HARNESS_PREAMBLE() \ | 447 HARNESS_PREAMBLE() \ |
| 448 func "\n" HARNESS_POSTAMBLE(); \ | 448 func "\n" HARNESS_POSTAMBLE(); \ |
| 449 \ | 449 \ |
| 450 v8::V8::Initialize(); \ | 450 v8::V8::Initialize(); \ |
| 451 HandleAndZoneScope handles; \ | 451 HandleAndZoneScope handles; \ |
| 452 Zone* zone = handles.main_zone(); \ | 452 Zone* zone = handles.main_zone(); \ |
| 453 ZoneVector<ExpressionTypeEntry> types(zone); \ | 453 ZoneVector<ExpressionTypeEntry> types(zone); \ |
| 454 CHECK_EQ("", Validate(zone, test_function, &types)); \ | 454 CHECK_EQ("", Validate(zone, test_function, &types)); \ |
| 455 ZoneTypeCache cache; \ | 455 TypeCache cache; \ |
| 456 \ | 456 \ |
| 457 CHECK_TYPES_BEGIN { \ | 457 CHECK_TYPES_BEGIN { \ |
| 458 /* Module. */ \ | 458 /* Module. */ \ |
| 459 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { | 459 CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) { |
| 460 #define CHECK_FUNC_TYPES_END_1() \ | 460 #define CHECK_FUNC_TYPES_END_1() \ |
| 461 /* "use asm"; */ \ | 461 /* "use asm"; */ \ |
| 462 CHECK_EXPR(Literal, Bounds(Type::String())); \ | 462 CHECK_EXPR(Literal, Bounds(Type::String())); \ |
| 463 /* stdlib shortcuts. */ \ | 463 /* stdlib shortcuts. */ \ |
| 464 CheckStdlibShortcuts(zone, types, index, depth, cache); | 464 CheckStdlibShortcuts(zone, types, index, depth, cache); |
| 465 | 465 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 "return {foo: foo, bar: 1};" | 907 "return {foo: foo, bar: 1};" |
| 908 "}\n"; | 908 "}\n"; |
| 909 | 909 |
| 910 v8::V8::Initialize(); | 910 v8::V8::Initialize(); |
| 911 HandleAndZoneScope handles; | 911 HandleAndZoneScope handles; |
| 912 Zone* zone = handles.main_zone(); | 912 Zone* zone = handles.main_zone(); |
| 913 ZoneVector<ExpressionTypeEntry> types(zone); | 913 ZoneVector<ExpressionTypeEntry> types(zone); |
| 914 CHECK_EQ("asm: line 40: non-function in function table\n", | 914 CHECK_EQ("asm: line 40: non-function in function table\n", |
| 915 Validate(zone, test_function, &types)); | 915 Validate(zone, test_function, &types)); |
| 916 } | 916 } |
| OLD | NEW |