OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/v8.h" |
| 6 |
| 7 #include "src/ast.h" |
| 8 #include "src/ast-expression-visitor.h" |
| 9 #include "src/parser.h" |
| 10 #include "src/rewriter.h" |
| 11 #include "src/scopes.h" |
| 12 #include "src/typing-asm.h" |
| 13 #include "src/zone-type-cache.h" |
| 14 #include "test/cctest/cctest.h" |
| 15 #include "test/cctest/expression-type-collector.h" |
| 16 #include "test/cctest/expression-type-collector-macros.h" |
| 17 |
| 18 // Macros for function types. |
| 19 #define FUNC_V_TYPE Bounds(Type::Function(Type::Undefined(), zone)) |
| 20 #define FUNC_I_TYPE Bounds(Type::Function(cache.kInt32, zone)) |
| 21 #define FUNC_F_TYPE Bounds(Type::Function(cache.kFloat32, zone)) |
| 22 #define FUNC_D_TYPE Bounds(Type::Function(cache.kFloat64, zone)) |
| 23 #define FUNC_D2D_TYPE \ |
| 24 Bounds(Type::Function(cache.kFloat64, cache.kFloat64, zone)) |
| 25 #define FUNC_N2F_TYPE \ |
| 26 Bounds(Type::Function(cache.kFloat32, Type::Number(), zone)) |
| 27 #define FUNC_I2I_TYPE Bounds(Type::Function(cache.kInt32, cache.kInt32, zone)) |
| 28 #define FUNC_II2D_TYPE \ |
| 29 Bounds(Type::Function(cache.kFloat64, cache.kInt32, cache.kInt32, zone)) |
| 30 #define FUNC_II2I_TYPE \ |
| 31 Bounds(Type::Function(cache.kInt32, cache.kInt32, cache.kInt32, zone)) |
| 32 #define FUNC_DD2D_TYPE \ |
| 33 Bounds(Type::Function(cache.kFloat64, cache.kFloat64, cache.kFloat64, zone)) |
| 34 #define FUNC_N2N_TYPE \ |
| 35 Bounds(Type::Function(Type::Number(), Type::Number(), zone)) |
| 36 |
| 37 // Macros for array types. |
| 38 #define FLOAT64_ARRAY_TYPE Bounds(Type::Array(cache.kFloat64, zone)) |
| 39 #define FUNC_I2I_ARRAY_TYPE \ |
| 40 Bounds(Type::Array(Type::Function(cache.kInt32, cache.kInt32, zone), zone)) |
| 41 |
| 42 using namespace v8::internal; |
| 43 |
| 44 namespace { |
| 45 |
| 46 std::string Validate(Zone* zone, const char* source, |
| 47 ZoneVector<ExpressionTypeEntry>* types) { |
| 48 i::Isolate* isolate = CcTest::i_isolate(); |
| 49 i::Factory* factory = isolate->factory(); |
| 50 |
| 51 i::Handle<i::String> source_code = |
| 52 factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); |
| 53 |
| 54 i::Handle<i::Script> script = factory->NewScript(source_code); |
| 55 |
| 56 i::ParseInfo info(zone, script); |
| 57 i::Parser parser(&info); |
| 58 parser.set_allow_harmony_arrow_functions(true); |
| 59 parser.set_allow_harmony_sloppy(true); |
| 60 info.set_global(); |
| 61 info.set_lazy(false); |
| 62 info.set_allow_lazy_parsing(false); |
| 63 info.set_toplevel(true); |
| 64 |
| 65 i::CompilationInfo compilation_info(&info); |
| 66 CHECK(i::Compiler::ParseAndAnalyze(&info)); |
| 67 info.set_literal( |
| 68 info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); |
| 69 |
| 70 AsmTyper typer(&compilation_info); |
| 71 if (typer.Validate()) { |
| 72 ExpressionTypeCollector(&compilation_info, types).Run(); |
| 73 return ""; |
| 74 } else { |
| 75 return typer.error_message(); |
| 76 } |
| 77 } |
| 78 } |
| 79 |
| 80 |
| 81 TEST(ValidateMinimum) { |
| 82 const char test_function[] = |
| 83 "function GeometricMean(stdlib, foreign, buffer) {\n" |
| 84 " \"use asm\";\n" |
| 85 "\n" |
| 86 " var exp = stdlib.Math.exp;\n" |
| 87 " var log = stdlib.Math.log;\n" |
| 88 " var values = new stdlib.Float64Array(buffer);\n" |
| 89 "\n" |
| 90 " function logSum(start, end) {\n" |
| 91 " start = start|0;\n" |
| 92 " end = end|0;\n" |
| 93 "\n" |
| 94 " var sum = 0.0, p = 0, q = 0;\n" |
| 95 "\n" |
| 96 " // asm.js forces byte addressing of the heap by requiring shifting " |
| 97 "by 3\n" |
| 98 " for (p = start << 3, q = end << 3; (p|0) < (q|0); p = (p + 8)|0) {\n" |
| 99 " sum = sum + +log(values[p>>3]);\n" |
| 100 " }\n" |
| 101 "\n" |
| 102 " return +sum;\n" |
| 103 " }\n" |
| 104 "\n" |
| 105 " function geometricMean(start, end) {\n" |
| 106 " start = start|0;\n" |
| 107 " end = end|0;\n" |
| 108 "\n" |
| 109 " return +exp(+logSum(start, end) / +((end - start)|0));\n" |
| 110 " }\n" |
| 111 "\n" |
| 112 " return { geometricMean: geometricMean };\n" |
| 113 "}\n"; |
| 114 |
| 115 v8::V8::Initialize(); |
| 116 HandleAndZoneScope handles; |
| 117 Zone* zone = handles.main_zone(); |
| 118 ZoneVector<ExpressionTypeEntry> types(zone); |
| 119 CHECK_EQ("", Validate(zone, test_function, &types)); |
| 120 ZoneTypeCache cache; |
| 121 |
| 122 CHECK_TYPES_BEGIN { |
| 123 // Module. |
| 124 CHECK_EXPR(FunctionLiteral, DEFAULT_TYPE) { |
| 125 // function logSum |
| 126 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { |
| 127 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 128 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 129 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 130 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 131 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 132 } |
| 133 } |
| 134 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 135 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 136 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 137 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 138 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 139 } |
| 140 } |
| 141 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { |
| 142 CHECK_VAR(sum, Bounds(cache.kFloat64)); |
| 143 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 144 } |
| 145 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 146 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 147 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 148 } |
| 149 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 150 CHECK_VAR(q, Bounds(cache.kInt32)); |
| 151 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 152 } |
| 153 // for (p = start << 3, q = end << 3; |
| 154 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 155 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 156 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 157 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 158 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 159 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 160 } |
| 161 } |
| 162 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 163 CHECK_VAR(q, Bounds(cache.kInt32)); |
| 164 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 165 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 166 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 167 } |
| 168 } |
| 169 } |
| 170 // (p|0) < (q|0); |
| 171 CHECK_EXPR(CompareOperation, Bounds(cache.kInt32)) { |
| 172 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 173 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 174 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 175 } |
| 176 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 177 CHECK_VAR(q, Bounds(cache.kInt32)); |
| 178 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 179 } |
| 180 } |
| 181 // p = (p + 8)|0) {\n" |
| 182 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 183 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 184 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 185 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 186 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 187 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 188 } |
| 189 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 190 } |
| 191 } |
| 192 // sum = sum + +log(values[p>>3]); |
| 193 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { |
| 194 CHECK_VAR(sum, Bounds(cache.kFloat64)); |
| 195 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 196 CHECK_VAR(sum, Bounds(cache.kFloat64)); |
| 197 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 198 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { |
| 199 CHECK_VAR(log, FUNC_D2D_TYPE); |
| 200 CHECK_EXPR(Property, Bounds(cache.kFloat64)) { |
| 201 CHECK_VAR(values, FLOAT64_ARRAY_TYPE); |
| 202 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 203 CHECK_VAR(p, Bounds(cache.kInt32)); |
| 204 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 205 } |
| 206 } |
| 207 } |
| 208 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 209 } |
| 210 } |
| 211 } |
| 212 // return +sum; |
| 213 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 214 CHECK_VAR(sum, Bounds(cache.kFloat64)); |
| 215 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 216 } |
| 217 } |
| 218 // function geometricMean |
| 219 CHECK_EXPR(FunctionLiteral, FUNC_II2D_TYPE) { |
| 220 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 221 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 222 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 223 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 224 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 225 } |
| 226 } |
| 227 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 228 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 229 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 230 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 231 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 232 } |
| 233 } |
| 234 // return +exp(+logSum(start, end) / +((end - start)|0)); |
| 235 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 236 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { |
| 237 CHECK_VAR(exp, FUNC_D2D_TYPE); |
| 238 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 239 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 240 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { |
| 241 CHECK_VAR(logSum, FUNC_II2D_TYPE); |
| 242 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 243 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 244 } |
| 245 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 246 } |
| 247 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 248 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 249 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 250 CHECK_VAR(end, Bounds(cache.kInt32)); |
| 251 CHECK_VAR(start, Bounds(cache.kInt32)); |
| 252 } |
| 253 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 254 } |
| 255 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 256 } |
| 257 } |
| 258 } |
| 259 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 260 } |
| 261 } |
| 262 // "use asm"; |
| 263 CHECK_EXPR(Literal, Bounds(Type::String())); |
| 264 // var exp = stdlib.Math.exp; |
| 265 CHECK_EXPR(Assignment, FUNC_D2D_TYPE) { |
| 266 CHECK_VAR(exp, FUNC_D2D_TYPE); |
| 267 CHECK_EXPR(Property, FUNC_D2D_TYPE) { |
| 268 CHECK_EXPR(Property, DEFAULT_TYPE) { |
| 269 CHECK_VAR(stdlib, DEFAULT_TYPE); |
| 270 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 271 } |
| 272 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 273 } |
| 274 } |
| 275 // var log = stdlib.Math.log; |
| 276 CHECK_EXPR(Assignment, FUNC_D2D_TYPE) { |
| 277 CHECK_VAR(log, FUNC_D2D_TYPE); |
| 278 CHECK_EXPR(Property, FUNC_D2D_TYPE) { |
| 279 CHECK_EXPR(Property, DEFAULT_TYPE) { |
| 280 CHECK_VAR(stdlib, DEFAULT_TYPE); |
| 281 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 282 } |
| 283 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 284 } |
| 285 } |
| 286 // var values = new stdlib.Float64Array(buffer); |
| 287 CHECK_EXPR(Assignment, FLOAT64_ARRAY_TYPE) { |
| 288 CHECK_VAR(values, FLOAT64_ARRAY_TYPE); |
| 289 CHECK_EXPR(CallNew, FLOAT64_ARRAY_TYPE) { |
| 290 CHECK_EXPR(Property, DEFAULT_TYPE) { |
| 291 CHECK_VAR(stdlib, DEFAULT_TYPE); |
| 292 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 293 } |
| 294 CHECK_VAR(buffer, DEFAULT_TYPE); |
| 295 } |
| 296 } |
| 297 // return { geometricMean: geometricMean }; |
| 298 CHECK_EXPR(ObjectLiteral, DEFAULT_TYPE) { |
| 299 CHECK_VAR(geometricMean, FUNC_II2D_TYPE); |
| 300 } |
| 301 } |
| 302 } |
| 303 CHECK_TYPES_END |
| 304 } |
| 305 |
| 306 |
| 307 #define HARNESS_STDLIB() \ |
| 308 "var Infinity = stdlib.Infinity;\n" \ |
| 309 "var NaN = stdlib.NaN;\n" \ |
| 310 "var acos = stdlib.Math.acos;\n" \ |
| 311 "var asin = stdlib.Math.asin;\n" \ |
| 312 "var atan = stdlib.Math.atan;\n" \ |
| 313 "var cos = stdlib.Math.cos;\n" \ |
| 314 "var sin = stdlib.Math.sin;\n" \ |
| 315 "var tan = stdlib.Math.tan;\n" \ |
| 316 "var exp = stdlib.Math.exp;\n" \ |
| 317 "var log = stdlib.Math.log;\n" \ |
| 318 "var ceil = stdlib.Math.ceil;\n" \ |
| 319 "var floor = stdlib.Math.floor;\n" \ |
| 320 "var sqrt = stdlib.Math.sqrt;\n" \ |
| 321 "var min = stdlib.Math.min;\n" \ |
| 322 "var max = stdlib.Math.max;\n" \ |
| 323 "var atan2 = stdlib.Math.atan2;\n" \ |
| 324 "var pow = stdlib.Math.pow;\n" \ |
| 325 "var abs = stdlib.Math.abs;\n" \ |
| 326 "var imul = stdlib.Math.imul;\n" \ |
| 327 "var fround = stdlib.Math.fround;\n" \ |
| 328 "var E = stdlib.Math.E;\n" \ |
| 329 "var LN10 = stdlib.Math.LN10;\n" \ |
| 330 "var LN2 = stdlib.Math.LN2;\n" \ |
| 331 "var LOG2E = stdlib.Math.LOG2E;\n" \ |
| 332 "var LOG10E = stdlib.Math.LOG10E;\n" \ |
| 333 "var PI = stdlib.Math.PI;\n" \ |
| 334 "var SQRT1_2 = stdlib.Math.SQRT1_2;\n" \ |
| 335 "var SQRT2 = stdlib.Math.SQRT2;\n" |
| 336 |
| 337 |
| 338 #define HARNESS_HEAP() \ |
| 339 "var u8 = new stdlib.Uint8Array(buffer);\n" \ |
| 340 "var i8 = new stdlib.Int8Array(buffer);\n" \ |
| 341 "var u16 = new stdlib.Uint16Array(buffer);\n" \ |
| 342 "var i16 = new stdlib.Int16Array(buffer);\n" \ |
| 343 "var u32 = new stdlib.Uint32Array(buffer);\n" \ |
| 344 "var i32 = new stdlib.Int32Array(buffer);\n" \ |
| 345 "var f32 = new stdlib.Float32Array(buffer);\n" \ |
| 346 "var f64 = new stdlib.Float64Array(buffer);\n" |
| 347 |
| 348 |
| 349 #define HARNESS_PREAMBLE() \ |
| 350 const char test_function[] = \ |
| 351 "function Module(stdlib, foreign, buffer) {\n" \ |
| 352 "\"use asm\";\n" HARNESS_STDLIB() HARNESS_HEAP() |
| 353 |
| 354 |
| 355 #define HARNESS_POSTAMBLE() \ |
| 356 "return { foo: foo };\n" \ |
| 357 "}\n"; |
| 358 |
| 359 |
| 360 #define CHECK_VAR_MATH_SHORTCUT(name, type) \ |
| 361 CHECK_EXPR(Assignment, type) { \ |
| 362 CHECK_VAR(name, type); \ |
| 363 CHECK_EXPR(Property, type) { \ |
| 364 CHECK_EXPR(Property, DEFAULT_TYPE) { \ |
| 365 CHECK_VAR(stdlib, DEFAULT_TYPE); \ |
| 366 CHECK_EXPR(Literal, DEFAULT_TYPE); \ |
| 367 } \ |
| 368 CHECK_EXPR(Literal, DEFAULT_TYPE); \ |
| 369 } \ |
| 370 } |
| 371 |
| 372 |
| 373 #define CHECK_VAR_SHORTCUT(name, type) \ |
| 374 CHECK_EXPR(Assignment, type) { \ |
| 375 CHECK_VAR(name, type); \ |
| 376 CHECK_EXPR(Property, type) { \ |
| 377 CHECK_VAR(stdlib, DEFAULT_TYPE); \ |
| 378 CHECK_EXPR(Literal, DEFAULT_TYPE); \ |
| 379 } \ |
| 380 } |
| 381 |
| 382 |
| 383 #define CHECK_VAR_NEW_SHORTCUT(name, type) \ |
| 384 CHECK_EXPR(Assignment, type) { \ |
| 385 CHECK_VAR(name, type); \ |
| 386 CHECK_EXPR(CallNew, type) { \ |
| 387 CHECK_EXPR(Property, DEFAULT_TYPE) { \ |
| 388 CHECK_VAR(stdlib, DEFAULT_TYPE); \ |
| 389 CHECK_EXPR(Literal, DEFAULT_TYPE); \ |
| 390 } \ |
| 391 CHECK_VAR(buffer, DEFAULT_TYPE); \ |
| 392 } \ |
| 393 } |
| 394 |
| 395 |
| 396 namespace { |
| 397 |
| 398 void CheckStdlibShortcuts(Zone* zone, ZoneVector<ExpressionTypeEntry>& types, |
| 399 size_t& index, int& depth, ZoneTypeCache& cache) { |
| 400 // var exp = stdlib.*; (D * 12) |
| 401 CHECK_VAR_SHORTCUT(Infinity, Bounds(cache.kFloat64)); |
| 402 CHECK_VAR_SHORTCUT(NaN, Bounds(cache.kFloat64)); |
| 403 // var x = stdlib.Math.x; D2D |
| 404 CHECK_VAR_MATH_SHORTCUT(acos, FUNC_D2D_TYPE); |
| 405 CHECK_VAR_MATH_SHORTCUT(asin, FUNC_D2D_TYPE); |
| 406 CHECK_VAR_MATH_SHORTCUT(atan, FUNC_D2D_TYPE); |
| 407 CHECK_VAR_MATH_SHORTCUT(cos, FUNC_D2D_TYPE); |
| 408 CHECK_VAR_MATH_SHORTCUT(sin, FUNC_D2D_TYPE); |
| 409 CHECK_VAR_MATH_SHORTCUT(tan, FUNC_D2D_TYPE); |
| 410 CHECK_VAR_MATH_SHORTCUT(exp, FUNC_D2D_TYPE); |
| 411 CHECK_VAR_MATH_SHORTCUT(log, FUNC_D2D_TYPE); |
| 412 CHECK_VAR_MATH_SHORTCUT(ceil, FUNC_D2D_TYPE); |
| 413 CHECK_VAR_MATH_SHORTCUT(floor, FUNC_D2D_TYPE); |
| 414 CHECK_VAR_MATH_SHORTCUT(sqrt, FUNC_D2D_TYPE); |
| 415 // var exp = stdlib.Math.*; (DD2D * 12) |
| 416 CHECK_VAR_MATH_SHORTCUT(min, FUNC_DD2D_TYPE); |
| 417 CHECK_VAR_MATH_SHORTCUT(max, FUNC_DD2D_TYPE); |
| 418 CHECK_VAR_MATH_SHORTCUT(atan2, FUNC_DD2D_TYPE); |
| 419 CHECK_VAR_MATH_SHORTCUT(pow, FUNC_DD2D_TYPE); |
| 420 // Special ones. |
| 421 CHECK_VAR_MATH_SHORTCUT(abs, FUNC_N2N_TYPE); |
| 422 CHECK_VAR_MATH_SHORTCUT(imul, FUNC_II2I_TYPE); |
| 423 CHECK_VAR_MATH_SHORTCUT(fround, FUNC_N2F_TYPE); |
| 424 // var exp = stdlib.Math.*; (D * 12) |
| 425 CHECK_VAR_MATH_SHORTCUT(E, Bounds(cache.kFloat64)); |
| 426 CHECK_VAR_MATH_SHORTCUT(LN10, Bounds(cache.kFloat64)); |
| 427 CHECK_VAR_MATH_SHORTCUT(LN2, Bounds(cache.kFloat64)); |
| 428 CHECK_VAR_MATH_SHORTCUT(LOG2E, Bounds(cache.kFloat64)); |
| 429 CHECK_VAR_MATH_SHORTCUT(LOG10E, Bounds(cache.kFloat64)); |
| 430 CHECK_VAR_MATH_SHORTCUT(PI, Bounds(cache.kFloat64)); |
| 431 CHECK_VAR_MATH_SHORTCUT(SQRT1_2, Bounds(cache.kFloat64)); |
| 432 CHECK_VAR_MATH_SHORTCUT(SQRT2, Bounds(cache.kFloat64)); |
| 433 // var values = new stdlib.*Array(buffer); |
| 434 CHECK_VAR_NEW_SHORTCUT(u8, Bounds(cache.kUint8Array)); |
| 435 CHECK_VAR_NEW_SHORTCUT(i8, Bounds(cache.kInt8Array)); |
| 436 CHECK_VAR_NEW_SHORTCUT(u16, Bounds(cache.kUint16Array)); |
| 437 CHECK_VAR_NEW_SHORTCUT(i16, Bounds(cache.kInt16Array)); |
| 438 CHECK_VAR_NEW_SHORTCUT(u32, Bounds(cache.kUint32Array)); |
| 439 CHECK_VAR_NEW_SHORTCUT(i32, Bounds(cache.kInt32Array)); |
| 440 CHECK_VAR_NEW_SHORTCUT(f32, Bounds(cache.kFloat32Array)); |
| 441 CHECK_VAR_NEW_SHORTCUT(f64, Bounds(cache.kFloat64Array)); |
| 442 } |
| 443 } |
| 444 |
| 445 |
| 446 #define CHECK_FUNC_TYPES_BEGIN(func) \ |
| 447 HARNESS_PREAMBLE() \ |
| 448 func "\n" HARNESS_POSTAMBLE(); \ |
| 449 \ |
| 450 v8::V8::Initialize(); \ |
| 451 HandleAndZoneScope handles; \ |
| 452 Zone* zone = handles.main_zone(); \ |
| 453 ZoneVector<ExpressionTypeEntry> types(zone); \ |
| 454 CHECK_EQ("", Validate(zone, test_function, &types)); \ |
| 455 ZoneTypeCache cache; \ |
| 456 \ |
| 457 CHECK_TYPES_BEGIN { \ |
| 458 /* Module. */ \ |
| 459 CHECK_EXPR(FunctionLiteral, DEFAULT_TYPE) { |
| 460 #define CHECK_FUNC_TYPES_END_1() \ |
| 461 /* "use asm"; */ \ |
| 462 CHECK_EXPR(Literal, Bounds(Type::String())); \ |
| 463 /* stdlib shortcuts. */ \ |
| 464 CheckStdlibShortcuts(zone, types, index, depth, cache); |
| 465 |
| 466 |
| 467 #define CHECK_FUNC_TYPES_END_2() \ |
| 468 /* return { foo: foo }; */ \ |
| 469 CHECK_EXPR(ObjectLiteral, DEFAULT_TYPE) { CHECK_VAR(foo, FUNC_V_TYPE); } \ |
| 470 } \ |
| 471 } \ |
| 472 CHECK_TYPES_END |
| 473 |
| 474 |
| 475 #define CHECK_FUNC_TYPES_END \ |
| 476 CHECK_FUNC_TYPES_END_1(); \ |
| 477 CHECK_FUNC_TYPES_END_2(); |
| 478 |
| 479 |
| 480 #define CHECK_FUNC_ERROR(func, message) \ |
| 481 HARNESS_PREAMBLE() \ |
| 482 func "\n" HARNESS_POSTAMBLE(); \ |
| 483 \ |
| 484 v8::V8::Initialize(); \ |
| 485 HandleAndZoneScope handles; \ |
| 486 Zone* zone = handles.main_zone(); \ |
| 487 ZoneVector<ExpressionTypeEntry> types(zone); \ |
| 488 CHECK_EQ(message, Validate(zone, test_function, &types)); |
| 489 |
| 490 |
| 491 TEST(BareHarness) { |
| 492 CHECK_FUNC_TYPES_BEGIN("function foo() {}") { |
| 493 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {} |
| 494 } |
| 495 CHECK_FUNC_TYPES_END |
| 496 } |
| 497 |
| 498 |
| 499 TEST(ReturnVoid) { |
| 500 CHECK_FUNC_TYPES_BEGIN( |
| 501 "function bar() { return; }\n" |
| 502 "function foo() { bar(); }") { |
| 503 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 504 // return undefined; |
| 505 CHECK_EXPR(Literal, Bounds(Type::Undefined())); |
| 506 } |
| 507 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 508 CHECK_EXPR(Call, Bounds(Type::Undefined())) { |
| 509 CHECK_VAR(bar, FUNC_V_TYPE); |
| 510 } |
| 511 } |
| 512 } |
| 513 CHECK_FUNC_TYPES_END |
| 514 } |
| 515 |
| 516 |
| 517 TEST(ReturnInt32Literal) { |
| 518 CHECK_FUNC_TYPES_BEGIN( |
| 519 "function bar() { return 1; }\n" |
| 520 "function foo() { bar(); }") { |
| 521 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 522 // return 1; |
| 523 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 524 } |
| 525 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 526 CHECK_EXPR(Call, Bounds(cache.kInt32)) { CHECK_VAR(bar, FUNC_I_TYPE); } |
| 527 } |
| 528 } |
| 529 CHECK_FUNC_TYPES_END |
| 530 } |
| 531 |
| 532 |
| 533 TEST(ReturnFloat64Literal) { |
| 534 CHECK_FUNC_TYPES_BEGIN( |
| 535 "function bar() { return 1.0; }\n" |
| 536 "function foo() { bar(); }") { |
| 537 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { |
| 538 // return 1.0; |
| 539 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 540 } |
| 541 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 542 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { CHECK_VAR(bar, FUNC_D_TYPE); } |
| 543 } |
| 544 } |
| 545 CHECK_FUNC_TYPES_END |
| 546 } |
| 547 |
| 548 |
| 549 TEST(ReturnFloat32Literal) { |
| 550 CHECK_FUNC_TYPES_BEGIN( |
| 551 "function bar() { return fround(1.0); }\n" |
| 552 "function foo() { bar(); }") { |
| 553 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { |
| 554 // return fround(1.0); |
| 555 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { |
| 556 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 557 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 558 } |
| 559 } |
| 560 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 561 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { CHECK_VAR(bar, FUNC_F_TYPE); } |
| 562 } |
| 563 } |
| 564 CHECK_FUNC_TYPES_END |
| 565 } |
| 566 |
| 567 |
| 568 TEST(ReturnFloat64Var) { |
| 569 CHECK_FUNC_TYPES_BEGIN( |
| 570 "function bar() { var x = 1.0; return +x; }\n" |
| 571 "function foo() { bar(); }") { |
| 572 CHECK_EXPR(FunctionLiteral, FUNC_D_TYPE) { |
| 573 // return 1.0; |
| 574 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) { |
| 575 CHECK_VAR(x, Bounds(cache.kFloat64)); |
| 576 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 577 } |
| 578 // return 1.0; |
| 579 CHECK_EXPR(BinaryOperation, Bounds(cache.kFloat64)) { |
| 580 CHECK_VAR(x, Bounds(cache.kFloat64)); |
| 581 CHECK_EXPR(Literal, Bounds(cache.kFloat64)); |
| 582 } |
| 583 } |
| 584 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 585 CHECK_EXPR(Call, Bounds(cache.kFloat64)) { CHECK_VAR(bar, FUNC_D_TYPE); } |
| 586 } |
| 587 } |
| 588 CHECK_FUNC_TYPES_END |
| 589 } |
| 590 |
| 591 |
| 592 TEST(Addition2) { |
| 593 CHECK_FUNC_TYPES_BEGIN( |
| 594 "function bar() { var x = 1; var y = 2; return (x+y)|0; }\n" |
| 595 "function foo() { bar(); }") { |
| 596 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 597 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 598 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 599 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 600 } |
| 601 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 602 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 603 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 604 } |
| 605 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 606 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 607 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 608 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 609 } |
| 610 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 611 } |
| 612 } |
| 613 CHECK_SKIP(); |
| 614 } |
| 615 CHECK_FUNC_TYPES_END |
| 616 } |
| 617 |
| 618 |
| 619 TEST(Addition4) { |
| 620 CHECK_FUNC_TYPES_BEGIN( |
| 621 "function bar() { var x = 1; var y = 2; return (x+y+x+y)|0; }\n" |
| 622 "function foo() { bar(); }") { |
| 623 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 624 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 625 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 626 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 627 } |
| 628 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 629 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 630 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 631 } |
| 632 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 633 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 634 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 635 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 636 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 637 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 638 } |
| 639 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 640 } |
| 641 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 642 } |
| 643 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 644 } |
| 645 } |
| 646 CHECK_SKIP(); |
| 647 } |
| 648 CHECK_FUNC_TYPES_END |
| 649 } |
| 650 |
| 651 |
| 652 TEST(Multiplication2) { |
| 653 CHECK_FUNC_ERROR( |
| 654 "function bar() { var x = 1; var y = 2; return (x*y)|0; }\n" |
| 655 "function foo() { bar(); }", |
| 656 "asm: line 39: direct integer multiply forbidden\n"); |
| 657 } |
| 658 |
| 659 |
| 660 TEST(Division4) { |
| 661 CHECK_FUNC_ERROR( |
| 662 "function bar() { var x = 1; var y = 2; return (x/y/x/y)|0; }\n" |
| 663 "function foo() { bar(); }", |
| 664 "asm: line 39: too many consecutive multiplicative ops\n"); |
| 665 } |
| 666 |
| 667 |
| 668 TEST(Load1) { |
| 669 CHECK_FUNC_TYPES_BEGIN( |
| 670 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" |
| 671 "function foo() { bar(); }") { |
| 672 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 673 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 674 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 675 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 676 } |
| 677 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 678 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 679 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 680 CHECK_EXPR(Property, Bounds(cache.kInt8)) { |
| 681 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
| 682 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 683 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 684 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 685 } |
| 686 } |
| 687 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 688 } |
| 689 } |
| 690 } |
| 691 CHECK_SKIP(); |
| 692 } |
| 693 CHECK_FUNC_TYPES_END |
| 694 } |
| 695 |
| 696 |
| 697 TEST(FunctionTables) { |
| 698 CHECK_FUNC_TYPES_BEGIN( |
| 699 "function func1(x) { x = x | 0; return (x * 5) | 0; }\n" |
| 700 "function func2(x) { x = x | 0; return (x * 25) | 0; }\n" |
| 701 "var table1 = [func1, func2];\n" |
| 702 "function bar(x, y) { x = x | 0; y = y | 0;\n" |
| 703 " return table1[x & 1](y)|0; }\n" |
| 704 "function foo() { bar(1, 2); }") { |
| 705 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { |
| 706 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 707 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 708 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 709 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 710 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 711 } |
| 712 } |
| 713 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 714 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 715 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 716 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 717 } |
| 718 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 719 } |
| 720 } |
| 721 CHECK_EXPR(FunctionLiteral, FUNC_I2I_TYPE) { |
| 722 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 723 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 724 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 725 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 726 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 727 } |
| 728 } |
| 729 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 730 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 731 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 732 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 733 } |
| 734 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 735 } |
| 736 } |
| 737 CHECK_EXPR(FunctionLiteral, FUNC_II2I_TYPE) { |
| 738 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 739 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 740 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 741 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 742 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 743 } |
| 744 } |
| 745 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { |
| 746 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 747 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 748 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 749 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 750 } |
| 751 } |
| 752 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 753 CHECK_EXPR(Call, Bounds(cache.kInt32)) { |
| 754 CHECK_EXPR(Property, FUNC_I2I_TYPE) { |
| 755 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); |
| 756 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 757 CHECK_VAR(x, Bounds(cache.kInt32)); |
| 758 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 759 } |
| 760 } |
| 761 CHECK_VAR(y, Bounds(cache.kInt32)); |
| 762 } |
| 763 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 764 } |
| 765 } |
| 766 CHECK_SKIP(); |
| 767 } |
| 768 CHECK_FUNC_TYPES_END_1(); |
| 769 CHECK_EXPR(Assignment, FUNC_I2I_ARRAY_TYPE) { |
| 770 CHECK_VAR(table1, FUNC_I2I_ARRAY_TYPE); |
| 771 CHECK_EXPR(ArrayLiteral, FUNC_I2I_ARRAY_TYPE) { |
| 772 CHECK_VAR(func1, FUNC_I2I_TYPE); |
| 773 CHECK_VAR(func2, FUNC_I2I_TYPE); |
| 774 } |
| 775 } |
| 776 CHECK_FUNC_TYPES_END_2(); |
| 777 } |
| 778 |
| 779 |
| 780 TEST(BadFunctionTable) { |
| 781 CHECK_FUNC_ERROR( |
| 782 "function func1(x) { x = x | 0; return (x * 5) | 0; }\n" |
| 783 "var table1 = [func1, 1];\n" |
| 784 "function bar(x, y) { x = x | 0; y = y | 0;\n" |
| 785 " return table1[x & 1](y)|0; }\n" |
| 786 "function foo() { bar(1, 2); }", |
| 787 "asm: line 40: array component expected to be a function\n"); |
| 788 } |
| 789 |
| 790 |
| 791 TEST(MissingParameterTypes) { |
| 792 CHECK_FUNC_ERROR( |
| 793 "function bar(x) { var y = 1; }\n" |
| 794 "function foo() { bar(2); }", |
| 795 "asm: line 39: missing parameter type annotations\n"); |
| 796 } |
| 797 |
| 798 |
| 799 TEST(InvalidTypeAnnotationBinaryOpDiv) { |
| 800 CHECK_FUNC_ERROR( |
| 801 "function bar(x) { x = x / 4; }\n" |
| 802 "function foo() { bar(2); }", |
| 803 "asm: line 39: invalid type annotation on binary op\n"); |
| 804 } |
| 805 |
| 806 |
| 807 TEST(InvalidTypeAnnotationBinaryOpMul) { |
| 808 CHECK_FUNC_ERROR( |
| 809 "function bar(x) { x = x * 4.0; }\n" |
| 810 "function foo() { bar(2); }", |
| 811 "asm: line 39: invalid type annotation on binary op\n"); |
| 812 } |
| 813 |
| 814 |
| 815 TEST(InvalidArgumentCount) { |
| 816 CHECK_FUNC_ERROR( |
| 817 "function bar(x) { return fround(4, 5); }\n" |
| 818 "function foo() { bar(); }", |
| 819 "asm: line 39: invalid argument count calling fround\n"); |
| 820 } |
| 821 |
| 822 |
| 823 TEST(InvalidTypeAnnotationArity) { |
| 824 CHECK_FUNC_ERROR( |
| 825 "function bar(x) { x = max(x); }\n" |
| 826 "function foo() { bar(3); }", |
| 827 "asm: line 39: only fround allowed on expression annotations\n"); |
| 828 } |
| 829 |
| 830 |
| 831 TEST(InvalidTypeAnnotationOnlyFround) { |
| 832 CHECK_FUNC_ERROR( |
| 833 "function bar(x) { x = sin(x); }\n" |
| 834 "function foo() { bar(3); }", |
| 835 "asm: line 39: only fround allowed on expression annotations\n"); |
| 836 } |
| 837 |
| 838 |
| 839 TEST(InvalidTypeAnnotation) { |
| 840 CHECK_FUNC_ERROR( |
| 841 "function bar(x) { x = (x+x)(x); }\n" |
| 842 "function foo() { bar(3); }", |
| 843 "asm: line 39: invalid type annotation\n"); |
| 844 } |
| 845 |
| 846 |
| 847 TEST(WithStatement) { |
| 848 CHECK_FUNC_ERROR( |
| 849 "function bar() { var x = 0; with (x) { x = x + 1; } }\n" |
| 850 "function foo() { bar(); }", |
| 851 "asm: line 39: bad with statement\n"); |
| 852 } |
| 853 |
| 854 |
| 855 TEST(NestedFunction) { |
| 856 CHECK_FUNC_ERROR( |
| 857 "function bar() { function x() { return 1; } }\n" |
| 858 "function foo() { bar(); }", |
| 859 "asm: line 39: function declared inside another\n"); |
| 860 } |
| 861 |
| 862 |
| 863 TEST(UnboundVariable) { |
| 864 CHECK_FUNC_ERROR( |
| 865 "function bar() { var x = y; }\n" |
| 866 "function foo() { bar(); }", |
| 867 "asm: line 39: unbound variable\n"); |
| 868 } |
| 869 |
| 870 |
| 871 TEST(ForeignFunction) { |
| 872 CHECK_FUNC_TYPES_BEGIN( |
| 873 "var baz = foreign.baz;\n" |
| 874 "function bar() { return baz(1, 2)|0; }\n" |
| 875 "function foo() { bar(); }") { |
| 876 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 877 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) { |
| 878 CHECK_EXPR(Call, Bounds(Type::Number(zone))) { |
| 879 CHECK_VAR(baz, Bounds(Type::Any())); |
| 880 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 881 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 882 } |
| 883 CHECK_EXPR(Literal, Bounds(cache.kInt32)); |
| 884 } |
| 885 } |
| 886 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 887 CHECK_EXPR(Call, Bounds(cache.kInt32)) { CHECK_VAR(bar, FUNC_I_TYPE); } |
| 888 } |
| 889 } |
| 890 CHECK_FUNC_TYPES_END_1() |
| 891 CHECK_EXPR(Assignment, Bounds(Type::Any())) { |
| 892 CHECK_VAR(baz, Bounds(Type::Any())); |
| 893 CHECK_EXPR(Property, Bounds(Type::Any())) { |
| 894 CHECK_VAR(foreign, DEFAULT_TYPE); |
| 895 CHECK_EXPR(Literal, DEFAULT_TYPE); |
| 896 } |
| 897 } |
| 898 CHECK_FUNC_TYPES_END_2() |
| 899 } |
| 900 |
| 901 |
| 902 TEST(BadExports) { |
| 903 HARNESS_PREAMBLE() |
| 904 "function foo() {};\n" |
| 905 "return {foo: foo, bar: 1};" |
| 906 "}\n"; |
| 907 |
| 908 v8::V8::Initialize(); |
| 909 HandleAndZoneScope handles; |
| 910 Zone* zone = handles.main_zone(); |
| 911 ZoneVector<ExpressionTypeEntry> types(zone); |
| 912 CHECK_EQ("asm: line 40: non-function in function table\n", |
| 913 Validate(zone, test_function, &types)); |
| 914 } |
OLD | NEW |