| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // of the full code. | 320 // of the full code. |
| 321 CHECK(f->IsOptimized()); | 321 CHECK(f->IsOptimized()); |
| 322 CHECK(f->shared()->has_deoptimization_support()); | 322 CHECK(f->shared()->has_deoptimization_support()); |
| 323 object = f->shared()->feedback_vector()->Get(slot_for_a); | 323 object = f->shared()->feedback_vector()->Get(slot_for_a); |
| 324 CHECK(object->IsWeakCell() && | 324 CHECK(object->IsWeakCell() && |
| 325 WeakCell::cast(object)->value()->IsJSFunction()); | 325 WeakCell::cast(object)->value()->IsJSFunction()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 | 328 |
| 329 TEST(FeedbackVectorUnaffectedByScopeChanges) { | 329 TEST(FeedbackVectorUnaffectedByScopeChanges) { |
| 330 if (i::FLAG_always_opt || !i::FLAG_lazy) return; | 330 if (i::FLAG_always_opt || !i::FLAG_lazy || |
| 331 (FLAG_ignition && FLAG_ignition_eager)) { |
| 332 return; |
| 333 } |
| 331 CcTest::InitializeVM(); | 334 CcTest::InitializeVM(); |
| 332 v8::HandleScope scope(CcTest::isolate()); | 335 v8::HandleScope scope(CcTest::isolate()); |
| 333 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); | 336 v8::Local<v8::Context> context = CcTest::isolate()->GetCurrentContext(); |
| 334 | 337 |
| 335 CompileRun("function builder() {" | 338 CompileRun("function builder() {" |
| 336 " call_target = function() { return 3; };" | 339 " call_target = function() { return 3; };" |
| 337 " return (function() {" | 340 " return (function() {" |
| 338 " eval('');" | 341 " eval('');" |
| 339 " return function() {" | 342 " return function() {" |
| 340 " 'use strict';" | 343 " 'use strict';" |
| 341 " call_target();" | 344 " call_target();" |
| 342 " }" | 345 " }" |
| 343 " })();" | 346 " })();" |
| 344 "}" | 347 "}" |
| 345 "morphing_call = builder();"); | 348 "morphing_call = builder();"); |
| 346 | 349 |
| 347 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 350 Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 348 *v8::Local<v8::Function>::Cast(CcTest::global() | 351 *v8::Local<v8::Function>::Cast(CcTest::global() |
| 349 ->Get(context, v8_str("morphing_call")) | 352 ->Get(context, v8_str("morphing_call")) |
| 350 .ToLocalChecked()))); | 353 .ToLocalChecked()))); |
| 351 | 354 |
| 352 // Not compiled, and so no feedback vector allocated yet. | 355 // If we are compiling lazily then it should not be compiled, and so no |
| 356 // feedback vector allocated yet. |
| 353 CHECK(!f->shared()->is_compiled()); | 357 CHECK(!f->shared()->is_compiled()); |
| 354 CHECK(f->shared()->feedback_vector()->is_empty()); | 358 CHECK(f->shared()->feedback_vector()->is_empty()); |
| 355 | 359 |
| 356 CompileRun("morphing_call();"); | 360 CompileRun("morphing_call();"); |
| 357 | 361 |
| 358 // Now a feedback vector is allocated. | 362 // Now a feedback vector is allocated. |
| 359 CHECK(f->shared()->is_compiled()); | 363 CHECK(f->shared()->is_compiled()); |
| 360 CHECK(!f->shared()->feedback_vector()->is_empty()); | 364 CHECK(!f->shared()->feedback_vector()->is_empty()); |
| 361 } | 365 } |
| 362 | 366 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 CompileRun("function f() { a = 12345678 }; f();"); | 756 CompileRun("function f() { a = 12345678 }; f();"); |
| 753 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 757 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 754 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 758 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
| 755 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 759 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 756 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 760 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
| 757 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 761 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 758 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 762 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
| 759 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 763 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 760 } | 764 } |
| 761 #endif | 765 #endif |
| OLD | NEW |