OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 "var closure0 = MakeClosure();" | 388 "var closure0 = MakeClosure();" |
389 "%DebugPrint(closure0());" | 389 "%DebugPrint(closure0());" |
390 "%OptimizeFunctionOnNextCall(closure0);" | 390 "%OptimizeFunctionOnNextCall(closure0);" |
391 "%DebugPrint(closure0());" | 391 "%DebugPrint(closure0());" |
392 "var closure1 = MakeClosure();" | 392 "var closure1 = MakeClosure();" |
393 "var closure2 = MakeClosure();"); | 393 "var closure2 = MakeClosure();"); |
394 Handle<JSFunction> fun1 = v8::Utils::OpenHandle( | 394 Handle<JSFunction> fun1 = v8::Utils::OpenHandle( |
395 *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1")))); | 395 *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1")))); |
396 Handle<JSFunction> fun2 = v8::Utils::OpenHandle( | 396 Handle<JSFunction> fun2 = v8::Utils::OpenHandle( |
397 *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2")))); | 397 *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2")))); |
398 CHECK(fun1->IsOptimized() | 398 CHECK(fun1->IsOptimized() || !CcTest::i_isolate()->use_crankshaft()); |
399 || !CcTest::i_isolate()->use_crankshaft() || !fun1->IsOptimizable()); | 399 CHECK(fun2->IsOptimized() || !CcTest::i_isolate()->use_crankshaft()); |
400 CHECK(fun2->IsOptimized() | |
401 || !CcTest::i_isolate()->use_crankshaft() || !fun2->IsOptimizable()); | |
402 CHECK_EQ(fun1->code(), fun2->code()); | 400 CHECK_EQ(fun1->code(), fun2->code()); |
403 } | 401 } |
404 } | 402 } |
405 | 403 |
406 | 404 |
407 TEST(CompileFunctionInContext) { | 405 TEST(CompileFunctionInContext) { |
408 CcTest::InitializeVM(); | 406 CcTest::InitializeVM(); |
409 v8::HandleScope scope(CcTest::isolate()); | 407 v8::HandleScope scope(CcTest::isolate()); |
410 LocalContext env; | 408 LocalContext env; |
411 CompileRun("var r = 10;"); | 409 CompileRun("var r = 10;"); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 CompileRun("function f() { a = 12345678 }; f();"); | 557 CompileRun("function f() { a = 12345678 }; f();"); |
560 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 558 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
561 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 559 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
562 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 560 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
563 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 561 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
564 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 562 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
565 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 563 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
566 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 564 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
567 } | 565 } |
568 #endif | 566 #endif |
OLD | NEW |