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/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-expression-visitor.h" | 8 #include "src/ast/ast-expression-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/parsing/parser.h" | 10 #include "src/parsing/parser.h" |
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 CHECK_VAR(ceil, FUNC_N2N_TYPE); | 2025 CHECK_VAR(ceil, FUNC_N2N_TYPE); |
2026 CHECK_VAR(x, Bounds(cache.kAsmFloat)); | 2026 CHECK_VAR(x, Bounds(cache.kAsmFloat)); |
2027 } | 2027 } |
2028 } | 2028 } |
2029 } | 2029 } |
2030 CHECK_SKIP(); | 2030 CHECK_SKIP(); |
2031 } | 2031 } |
2032 CHECK_FUNC_TYPES_END | 2032 CHECK_FUNC_TYPES_END |
2033 } | 2033 } |
2034 | 2034 |
| 2035 TEST(FloatReturnAsDouble) { |
| 2036 CHECK_FUNC_TYPES_BEGIN( |
| 2037 "function bar() { var x = fround(3.1); return +fround(x); }\n" |
| 2038 "function foo() { bar(); }") { |
| 2039 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { |
| 2040 CHECK_EXPR(Assignment, Bounds(cache.kAsmFloat)) { |
| 2041 CHECK_VAR(x, Bounds(cache.kAsmFloat)); |
| 2042 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
| 2043 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 2044 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 2045 } |
| 2046 } |
| 2047 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
| 2048 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
| 2049 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 2050 CHECK_VAR(x, Bounds(cache.kAsmFloat)); |
| 2051 } |
| 2052 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 2053 } |
| 2054 } |
| 2055 CHECK_SKIP(); |
| 2056 } |
| 2057 CHECK_FUNC_TYPES_END |
| 2058 } |
2035 | 2059 |
2036 TEST(TypeConsistency) { | 2060 TEST(TypeConsistency) { |
2037 v8::V8::Initialize(); | 2061 v8::V8::Initialize(); |
2038 TypeCache cache; | 2062 TypeCache cache; |
2039 // Check the consistency of each of the main Asm.js types. | 2063 // Check the consistency of each of the main Asm.js types. |
2040 CHECK(cache.kAsmFixnum->Is(cache.kAsmFixnum)); | 2064 CHECK(cache.kAsmFixnum->Is(cache.kAsmFixnum)); |
2041 CHECK(cache.kAsmFixnum->Is(cache.kAsmSigned)); | 2065 CHECK(cache.kAsmFixnum->Is(cache.kAsmSigned)); |
2042 CHECK(cache.kAsmFixnum->Is(cache.kAsmUnsigned)); | 2066 CHECK(cache.kAsmFixnum->Is(cache.kAsmUnsigned)); |
2043 CHECK(cache.kAsmFixnum->Is(cache.kAsmInt)); | 2067 CHECK(cache.kAsmFixnum->Is(cache.kAsmInt)); |
2044 CHECK(!cache.kAsmFixnum->Is(cache.kAsmFloat)); | 2068 CHECK(!cache.kAsmFixnum->Is(cache.kAsmFloat)); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { | 2405 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
2382 CHECK_VAR(x, Bounds(cache.kAsmDouble)); | 2406 CHECK_VAR(x, Bounds(cache.kAsmDouble)); |
2383 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); | 2407 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
2384 } | 2408 } |
2385 } | 2409 } |
2386 } | 2410 } |
2387 CHECK_SKIP(); | 2411 CHECK_SKIP(); |
2388 } | 2412 } |
2389 CHECK_FUNC_TYPES_END | 2413 CHECK_FUNC_TYPES_END |
2390 } | 2414 } |
OLD | NEW |