Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Side by Side Diff: src/ic/ic.cc

Issue 1925583002: Check the state of the current binary op IC before patching smi code (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-recurse-patch-binary-op.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/ic/ic.h" 5 #include "src/ic/ic.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/api-arguments.h" 9 #include "src/api-arguments.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 } 2350 }
2351 2351
2352 // Do not try to update the target if the code was marked for lazy 2352 // Do not try to update the target if the code was marked for lazy
2353 // deoptimization. (Since we do not relocate addresses in these 2353 // deoptimization. (Since we do not relocate addresses in these
2354 // code objects, an attempt to access the target could fail.) 2354 // code objects, an attempt to access the target could fail.)
2355 if (AddressIsDeoptimizedCode()) { 2355 if (AddressIsDeoptimizedCode()) {
2356 return result; 2356 return result;
2357 } 2357 }
2358 2358
2359 // Compute the new state. 2359 // Compute the new state.
2360 BinaryOpICState old_state(isolate(), extra_ic_state()); 2360 BinaryOpICState old_state(isolate(), target()->extra_ic_state());
2361 state.Update(left, right, result); 2361 state.Update(left, right, result);
2362 2362
2363 // Check if we have a string operation here. 2363 // Check if we have a string operation here.
2364 Handle<Code> target; 2364 Handle<Code> new_target;
2365 if (!allocation_site.is_null() || state.ShouldCreateAllocationMementos()) { 2365 if (!allocation_site.is_null() || state.ShouldCreateAllocationMementos()) {
2366 // Setup the allocation site on-demand. 2366 // Setup the allocation site on-demand.
2367 if (allocation_site.is_null()) { 2367 if (allocation_site.is_null()) {
2368 allocation_site = isolate()->factory()->NewAllocationSite(); 2368 allocation_site = isolate()->factory()->NewAllocationSite();
2369 } 2369 }
2370 2370
2371 // Install the stub with an allocation site. 2371 // Install the stub with an allocation site.
2372 BinaryOpICWithAllocationSiteStub stub(isolate(), state); 2372 BinaryOpICWithAllocationSiteStub stub(isolate(), state);
2373 target = stub.GetCodeCopyFromTemplate(allocation_site); 2373 new_target = stub.GetCodeCopyFromTemplate(allocation_site);
2374 2374
2375 // Sanity check the trampoline stub. 2375 // Sanity check the trampoline stub.
2376 DCHECK_EQ(*allocation_site, target->FindFirstAllocationSite()); 2376 DCHECK_EQ(*allocation_site, new_target->FindFirstAllocationSite());
2377 } else { 2377 } else {
2378 // Install the generic stub. 2378 // Install the generic stub.
2379 BinaryOpICStub stub(isolate(), state); 2379 BinaryOpICStub stub(isolate(), state);
2380 target = stub.GetCode(); 2380 new_target = stub.GetCode();
2381 2381
2382 // Sanity check the generic stub. 2382 // Sanity check the generic stub.
2383 DCHECK_NULL(target->FindFirstAllocationSite()); 2383 DCHECK_NULL(new_target->FindFirstAllocationSite());
2384 } 2384 }
2385 set_target(*target); 2385 set_target(*new_target);
2386 2386
2387 if (FLAG_trace_ic) { 2387 if (FLAG_trace_ic) {
2388 OFStream os(stdout); 2388 OFStream os(stdout);
2389 os << "[BinaryOpIC" << old_state << " => " << state << " @ " 2389 os << "[BinaryOpIC" << old_state << " => " << state << " @ "
2390 << static_cast<void*>(*target) << " <- "; 2390 << static_cast<void*>(*new_target) << " <- ";
2391 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); 2391 JavaScriptFrame::PrintTop(isolate(), stdout, false, true);
2392 if (!allocation_site.is_null()) { 2392 if (!allocation_site.is_null()) {
2393 os << " using allocation site " << static_cast<void*>(*allocation_site); 2393 os << " using allocation site " << static_cast<void*>(*allocation_site);
2394 } 2394 }
2395 os << "]" << std::endl; 2395 os << "]" << std::endl;
2396 } 2396 }
2397 2397
2398 // Patch the inlined smi code as necessary. 2398 // Patch the inlined smi code as necessary.
2399 if (!old_state.UseInlinedSmiCode() && state.UseInlinedSmiCode()) { 2399 if (!old_state.UseInlinedSmiCode() && state.UseInlinedSmiCode()) {
2400 PatchInlinedSmiCode(isolate(), address(), ENABLE_INLINED_SMI_CHECK); 2400 PatchInlinedSmiCode(isolate(), address(), ENABLE_INLINED_SMI_CHECK);
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 KeyedLoadICNexus nexus(vector, vector_slot); 2744 KeyedLoadICNexus nexus(vector, vector_slot);
2745 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); 2745 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
2746 ic.UpdateState(receiver, key); 2746 ic.UpdateState(receiver, key);
2747 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); 2747 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
2748 } 2748 }
2749 2749
2750 return *result; 2750 return *result;
2751 } 2751 }
2752 } // namespace internal 2752 } // namespace internal
2753 } // namespace v8 2753 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-recurse-patch-binary-op.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698