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

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

Issue 2052763003: [ic] [stubs] Remove InlineCacheState field from the code flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 6 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 | « src/ic/ic.h ('k') | src/ic/stub-cache.cc » ('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-arguments-inl.h" 8 #include "src/api-arguments-inl.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 27 matching lines...) Expand all
38 case MONOMORPHIC: 38 case MONOMORPHIC:
39 return '1'; 39 return '1';
40 case RECOMPUTE_HANDLER: 40 case RECOMPUTE_HANDLER:
41 return '^'; 41 return '^';
42 case POLYMORPHIC: 42 case POLYMORPHIC:
43 return 'P'; 43 return 'P';
44 case MEGAMORPHIC: 44 case MEGAMORPHIC:
45 return 'N'; 45 return 'N';
46 case GENERIC: 46 case GENERIC:
47 return 'G'; 47 return 'G';
48
49 // We never see the debugger states here, because the state is
50 // computed from the original code - not the patched code. Let
51 // these cases fall through to the unreachable code below.
52 case DEBUG_STUB:
53 break;
54 } 48 }
55 UNREACHABLE(); 49 UNREACHABLE();
56 return 0; 50 return 0;
57 } 51 }
58 52
59 53
60 const char* GetTransitionMarkModifier(KeyedAccessStoreMode mode) { 54 const char* GetTransitionMarkModifier(KeyedAccessStoreMode mode) {
61 if (mode == STORE_NO_TRANSITION_HANDLE_COW) return ".COW"; 55 if (mode == STORE_NO_TRANSITION_HANDLE_COW) return ".COW";
62 if (mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { 56 if (mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) {
63 return ".IGNORE_OOB"; 57 return ".IGNORE_OOB";
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 StackFrame* frame = it.frame(); 170 StackFrame* frame = it.frame();
177 DCHECK(fp == frame->fp() && pc_address == frame->pc_address()); 171 DCHECK(fp == frame->fp() && pc_address == frame->pc_address());
178 #endif 172 #endif
179 fp_ = fp; 173 fp_ = fp;
180 if (FLAG_enable_embedded_constant_pool) { 174 if (FLAG_enable_embedded_constant_pool) {
181 constant_pool_address_ = constant_pool; 175 constant_pool_address_ = constant_pool;
182 } 176 }
183 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address); 177 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address);
184 Code* target = this->target(); 178 Code* target = this->target();
185 kind_ = target->kind(); 179 kind_ = target->kind();
186 state_ = UseVector() ? nexus->StateFromFeedback() : target->ic_state(); 180 state_ = UseVector() ? nexus->StateFromFeedback() : StateFromCode(target);
187 old_state_ = state_; 181 old_state_ = state_;
188 extra_ic_state_ = target->extra_ic_state(); 182 extra_ic_state_ = target->extra_ic_state();
189 } 183 }
190 184
185 InlineCacheState IC::StateFromCode(Code* code) {
186 Isolate* isolate = code->GetIsolate();
187 switch (code->kind()) {
188 case Code::BINARY_OP_IC: {
189 BinaryOpICState state(isolate, code->extra_ic_state());
190 return state.GetICState();
191 }
192 case Code::COMPARE_IC: {
193 CompareICStub stub(isolate, code->extra_ic_state());
194 return stub.GetICState();
195 }
196 case Code::TO_BOOLEAN_IC: {
197 ToBooleanICStub stub(isolate, code->extra_ic_state());
198 return stub.GetICState();
199 }
200 default:
201 if (code->is_debug_stub()) return UNINITIALIZED;
202 UNREACHABLE();
203 return UNINITIALIZED;
204 }
205 }
191 206
192 SharedFunctionInfo* IC::GetSharedFunctionInfo() const { 207 SharedFunctionInfo* IC::GetSharedFunctionInfo() const {
193 // Compute the JavaScript frame for the frame pointer of this IC 208 // Compute the JavaScript frame for the frame pointer of this IC
194 // structure. We need this to be able to find the function 209 // structure. We need this to be able to find the function
195 // corresponding to the frame. 210 // corresponding to the frame.
196 StackFrameIterator it(isolate()); 211 StackFrameIterator it(isolate());
197 while (it.frame()->fp() != this->fp()) it.Advance(); 212 while (it.frame()->fp() != this->fp()) it.Advance();
198 if (FLAG_ignition && it.frame()->type() == StackFrame::STUB) { 213 if (FLAG_ignition && it.frame()->type() == StackFrame::STUB) {
199 // Advance over bytecode handler frame. 214 // Advance over bytecode handler frame.
200 // TODO(rmcilroy): Remove this once bytecode handlers don't need a frame. 215 // TODO(rmcilroy): Remove this once bytecode handlers don't need a frame.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 break; 362 break;
348 case MEGAMORPHIC: 363 case MEGAMORPHIC:
349 case GENERIC: 364 case GENERIC:
350 if (new_state == MEGAMORPHIC || new_state == GENERIC) break; 365 if (new_state == MEGAMORPHIC || new_state == GENERIC) break;
351 *generic_delta = -1; 366 *generic_delta = -1;
352 if (new_state == MONOMORPHIC || new_state == POLYMORPHIC) { 367 if (new_state == MONOMORPHIC || new_state == POLYMORPHIC) {
353 *polymorphic_delta = 1; 368 *polymorphic_delta = 1;
354 } 369 }
355 break; 370 break;
356 case RECOMPUTE_HANDLER: 371 case RECOMPUTE_HANDLER:
357 case DEBUG_STUB:
358 UNREACHABLE(); 372 UNREACHABLE();
359 } 373 }
360 } 374 }
361 375
362 // static 376 // static
363 void IC::OnTypeFeedbackChanged(Isolate* isolate, Code* host) { 377 void IC::OnTypeFeedbackChanged(Isolate* isolate, Code* host) {
364 if (host->kind() != Code::FUNCTION) return; 378 if (host->kind() != Code::FUNCTION) return;
365 379
366 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(host->type_feedback_info()); 380 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(host->type_feedback_info());
367 info->change_own_type_change_checksum(); 381 info->change_own_type_change_checksum();
368 host->set_profiler_ticks(0); 382 host->set_profiler_ticks(0);
369 isolate->runtime_profiler()->NotifyICChanged(); 383 isolate->runtime_profiler()->NotifyICChanged();
370 // TODO(2029): When an optimized function is patched, it would 384 // TODO(2029): When an optimized function is patched, it would
371 // be nice to propagate the corresponding type information to its 385 // be nice to propagate the corresponding type information to its
372 // unoptimized version for the benefit of later inlining. 386 // unoptimized version for the benefit of later inlining.
373 } 387 }
374 388
375 void IC::PostPatching(Address address, Code* target, Code* old_target) { 389 void IC::PostPatching(Address address, Code* target, Code* old_target) {
376 // Type vector based ICs update these statistics at a different time because 390 // Type vector based ICs update these statistics at a different time because
377 // they don't always patch on state change. 391 // they don't always patch on state change.
378 if (ICUseVector(target->kind())) return; 392 if (ICUseVector(target->kind())) return;
379 393
380 DCHECK(old_target->is_inline_cache_stub()); 394 DCHECK(old_target->is_inline_cache_stub());
381 DCHECK(target->is_inline_cache_stub()); 395 DCHECK(target->is_inline_cache_stub());
382 State old_state = old_target->ic_state(); 396 State old_state = StateFromCode(old_target);
383 State new_state = target->ic_state(); 397 State new_state = StateFromCode(target);
384 398
385 Isolate* isolate = target->GetIsolate(); 399 Isolate* isolate = target->GetIsolate();
386 Code* host = 400 Code* host =
387 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code; 401 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code;
388 if (host->kind() != Code::FUNCTION) return; 402 if (host->kind() != Code::FUNCTION) return;
389 403
390 // Not all Code objects have TypeFeedbackInfo. 404 // Not all Code objects have TypeFeedbackInfo.
391 if (host->type_feedback_info()->IsTypeFeedbackInfo()) { 405 if (host->type_feedback_info()->IsTypeFeedbackInfo()) {
392 if (FLAG_type_info_threshold > 0) { 406 if (FLAG_type_info_threshold > 0) {
393 int polymorphic_delta = 0; // "Polymorphic" here includes monomorphic. 407 int polymorphic_delta = 0; // "Polymorphic" here includes monomorphic.
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 801 }
788 DCHECK(UseVector()); 802 DCHECK(UseVector());
789 ConfigureVectorState(MEGAMORPHIC, name); 803 ConfigureVectorState(MEGAMORPHIC, name);
790 // Fall through. 804 // Fall through.
791 case MEGAMORPHIC: 805 case MEGAMORPHIC:
792 UpdateMegamorphicCache(*receiver_map(), *name, *code); 806 UpdateMegamorphicCache(*receiver_map(), *name, *code);
793 // Indicate that we've handled this case. 807 // Indicate that we've handled this case.
794 DCHECK(UseVector()); 808 DCHECK(UseVector());
795 vector_set_ = true; 809 vector_set_ = true;
796 break; 810 break;
797 case DEBUG_STUB:
798 break;
799 case GENERIC: 811 case GENERIC:
800 UNREACHABLE(); 812 UNREACHABLE();
801 break; 813 break;
802 } 814 }
803 } 815 }
804 816
805 Handle<Code> LoadIC::initialize_stub_in_optimized_code( 817 Handle<Code> LoadIC::initialize_stub_in_optimized_code(
806 Isolate* isolate, ExtraICState extra_state) { 818 Isolate* isolate, ExtraICState extra_state) {
807 if (FLAG_tf_load_ic_stub) { 819 if (FLAG_tf_load_ic_stub) {
808 return LoadICTFStub(isolate, LoadICState(extra_state)).GetCode(); 820 return LoadICTFStub(isolate, LoadICState(extra_state)).GetCode();
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, 2950 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC,
2939 vector->GetKind(vector_slot)); 2951 vector->GetKind(vector_slot));
2940 KeyedLoadICNexus nexus(vector, vector_slot); 2952 KeyedLoadICNexus nexus(vector, vector_slot);
2941 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); 2953 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus);
2942 ic.UpdateState(receiver, key); 2954 ic.UpdateState(receiver, key);
2943 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); 2955 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key));
2944 } 2956 }
2945 } 2957 }
2946 } // namespace internal 2958 } // namespace internal
2947 } // namespace v8 2959 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698