Chromium Code Reviews| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 289 |
| 290 | 290 |
| 291 Failure* IC::ReferenceError(const char* type, Handle<String> name) { | 291 Failure* IC::ReferenceError(const char* type, Handle<String> name) { |
| 292 HandleScope scope(isolate()); | 292 HandleScope scope(isolate()); |
| 293 Handle<Object> error = isolate()->factory()->NewReferenceError( | 293 Handle<Object> error = isolate()->factory()->NewReferenceError( |
| 294 type, HandleVector(&name, 1)); | 294 type, HandleVector(&name, 1)); |
| 295 return isolate()->Throw(*error); | 295 return isolate()->Throw(*error); |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 static int ComputeTypeinfoCountDelta(IC::State old_state, IC::State new_state) { | |
|
ulan
2012/03/27 11:40:58
Uppercase i in TypeInfo is better.
Jakob Kummerow
2012/03/27 12:19:10
Done.
| |
| 300 bool was_uninitialized = | |
| 301 old_state == UNINITIALIZED || old_state == PREMONOMORPHIC; | |
| 302 bool is_uninitialized = | |
| 303 new_state == UNINITIALIZED || new_state == PREMONOMORPHIC; | |
| 304 if (was_uninitialized && !is_uninitialized) { | |
|
ulan
2012/03/27 11:40:58
You may disagree, but I like:
return (was_uninitia
Jakob Kummerow
2012/03/27 12:19:10
Done.
| |
| 305 return 1; | |
| 306 } else if (!was_uninitialized && is_uninitialized) { | |
| 307 return -1; | |
| 308 } | |
| 309 return 0; | |
| 310 } | |
| 311 | |
| 312 | |
| 299 void IC::PostPatching(Address address, Code* target, Code* old_target) { | 313 void IC::PostPatching(Address address, Code* target, Code* old_target) { |
| 300 if (FLAG_type_info_threshold > 0) { | 314 if (FLAG_type_info_threshold == 0 && |
|
ulan
2012/03/27 11:40:58
Doesn't it fit into one line?
Jakob Kummerow
2012/03/27 12:19:10
Done.
| |
| 301 if (old_target->is_inline_cache_stub() && | 315 !FLAG_watch_ic_patching) { |
| 302 target->is_inline_cache_stub()) { | 316 return; |
| 303 State old_state = old_target->ic_state(); | 317 } |
| 304 State new_state = target->ic_state(); | 318 Code* host = target->GetHeap()->isolate()-> |
| 305 bool was_uninitialized = | 319 inner_pointer_to_code_cache()->GetCacheEntry(address)->code; |
| 306 old_state == UNINITIALIZED || old_state == PREMONOMORPHIC; | 320 if (host->kind() != Code::FUNCTION) return; |
|
ulan
2012/03/27 11:40:58
I am not sure here. Is it safe to ignore other kin
Jakob Kummerow
2012/03/27 12:19:10
Yes, because only Code objects with kind() == FUNC
| |
| 307 bool is_uninitialized = | 321 |
| 308 new_state == UNINITIALIZED || new_state == PREMONOMORPHIC; | 322 if (FLAG_type_info_threshold > 0 && |
| 309 int delta = 0; | 323 old_target->is_inline_cache_stub() && |
| 310 if (was_uninitialized && !is_uninitialized) { | 324 target->is_inline_cache_stub()) { |
| 311 delta = 1; | 325 int delta = ComputeTypeinfoCountDelta(old_target->ic_state(), |
| 312 } else if (!was_uninitialized && is_uninitialized) { | 326 target->ic_state()); |
| 313 delta = -1; | 327 // Not all Code objects have TypeFeedbackInfo. |
| 314 } | 328 if (delta != 0 && host->type_feedback_info()->IsTypeFeedbackInfo()) { |
| 315 if (delta != 0) { | 329 TypeFeedbackInfo* info = |
| 316 Code* host = target->GetHeap()->isolate()-> | 330 TypeFeedbackInfo::cast(host->type_feedback_info()); |
| 317 inner_pointer_to_code_cache()->GetCacheEntry(address)->code; | 331 info->set_ic_with_typeinfo_count(info->ic_with_typeinfo_count() + delta); |
| 318 // Not all Code objects have TypeFeedbackInfo. | |
| 319 if (host->type_feedback_info()->IsTypeFeedbackInfo()) { | |
| 320 TypeFeedbackInfo* info = | |
| 321 TypeFeedbackInfo::cast(host->type_feedback_info()); | |
| 322 info->set_ic_with_typeinfo_count( | |
| 323 info->ic_with_typeinfo_count() + delta); | |
| 324 } | |
| 325 } | |
| 326 } | 332 } |
| 327 } | 333 } |
| 328 if (FLAG_watch_ic_patching) { | 334 if (FLAG_watch_ic_patching) { |
| 335 host->set_profiler_ticks(0); | |
| 329 Isolate::Current()->runtime_profiler()->NotifyICChanged(); | 336 Isolate::Current()->runtime_profiler()->NotifyICChanged(); |
| 330 // We do not want to optimize until the ICs have settled down, | |
| 331 // so when they are patched, we postpone optimization for the | |
| 332 // current function and the functions above it on the stack that | |
| 333 // might want to inline this one. | |
| 334 StackFrameIterator it; | |
| 335 if (it.done()) return; | |
| 336 it.Advance(); | |
| 337 static const int kStackFramesToMark = Compiler::kMaxInliningLevels - 1; | |
| 338 for (int i = 0; i < kStackFramesToMark; ++i) { | |
| 339 if (it.done()) return; | |
| 340 StackFrame* raw_frame = it.frame(); | |
| 341 if (raw_frame->is_java_script()) { | |
| 342 JSFunction* function = | |
| 343 JSFunction::cast(JavaScriptFrame::cast(raw_frame)->function()); | |
| 344 if (function->IsOptimized()) continue; | |
| 345 SharedFunctionInfo* shared = function->shared(); | |
| 346 shared->set_profiler_ticks(0); | |
| 347 } | |
| 348 it.Advance(); | |
| 349 } | |
| 350 } | 337 } |
| 338 // TODO(2029): When an optimized function is patched, it would | |
| 339 // be nice to propagate the corresponding type information to its | |
| 340 // unoptimized version for the benefit of later inlining. | |
| 351 } | 341 } |
| 352 | 342 |
| 353 | 343 |
| 354 void IC::Clear(Address address) { | 344 void IC::Clear(Address address) { |
| 355 Code* target = GetTargetAtAddress(address); | 345 Code* target = GetTargetAtAddress(address); |
| 356 | 346 |
| 357 // Don't clear debug break inline cache as it will remove the break point. | 347 // Don't clear debug break inline cache as it will remove the break point. |
| 358 if (target->ic_state() == DEBUG_BREAK) return; | 348 if (target->ic_state() == DEBUG_BREAK) return; |
| 359 | 349 |
| 360 switch (target->kind()) { | 350 switch (target->kind()) { |
| (...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2577 #undef ADDR | 2567 #undef ADDR |
| 2578 }; | 2568 }; |
| 2579 | 2569 |
| 2580 | 2570 |
| 2581 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2571 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2582 return IC_utilities[id]; | 2572 return IC_utilities[id]; |
| 2583 } | 2573 } |
| 2584 | 2574 |
| 2585 | 2575 |
| 2586 } } // namespace v8::internal | 2576 } } // namespace v8::internal |
| OLD | NEW |