| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.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/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 | 322 |
| 323 MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<String> name) { | 323 MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<String> name) { |
| 324 HandleScope scope(isolate()); | 324 HandleScope scope(isolate()); |
| 325 Handle<Object> error = isolate()->factory()->NewReferenceError( | 325 Handle<Object> error = isolate()->factory()->NewReferenceError( |
| 326 type, HandleVector(&name, 1)); | 326 type, HandleVector(&name, 1)); |
| 327 return isolate()->Throw<Object>(error); | 327 return isolate()->Throw<Object>(error); |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 static int ComputeTypeInfoCountDelta(IC::State old_state, IC::State new_state) { | 331 static void ComputeTypeInfoCountDelta(IC::State old_state, IC::State new_state, |
| 332 bool was_uninitialized = | 332 int* polymorphic_delta, |
| 333 old_state == UNINITIALIZED || old_state == PREMONOMORPHIC; | 333 int* generic_delta) { |
| 334 bool is_uninitialized = | 334 switch (old_state) { |
| 335 new_state == UNINITIALIZED || new_state == PREMONOMORPHIC; | 335 case UNINITIALIZED: |
| 336 return (was_uninitialized && !is_uninitialized) ? 1 : | 336 case PREMONOMORPHIC: |
| 337 (!was_uninitialized && is_uninitialized) ? -1 : 0; | 337 if (new_state == UNINITIALIZED || new_state == PREMONOMORPHIC) break; |
| 338 if (new_state == MONOMORPHIC || new_state == POLYMORPHIC) { |
| 339 *polymorphic_delta = 1; |
| 340 } else if (new_state == MEGAMORPHIC || new_state == GENERIC) { |
| 341 *generic_delta = 1; |
| 342 } |
| 343 break; |
| 344 case MONOMORPHIC: |
| 345 case POLYMORPHIC: |
| 346 if (new_state == MONOMORPHIC || new_state == POLYMORPHIC) break; |
| 347 *polymorphic_delta = -1; |
| 348 if (new_state == MEGAMORPHIC || new_state == GENERIC) { |
| 349 *generic_delta = 1; |
| 350 } |
| 351 break; |
| 352 case MEGAMORPHIC: |
| 353 case GENERIC: |
| 354 if (new_state == MEGAMORPHIC || new_state == GENERIC) break; |
| 355 *generic_delta = -1; |
| 356 if (new_state == MONOMORPHIC || new_state == POLYMORPHIC) { |
| 357 *polymorphic_delta = 1; |
| 358 } |
| 359 break; |
| 360 case PROTOTYPE_FAILURE: |
| 361 case DEBUG_STUB: |
| 362 UNREACHABLE(); |
| 363 } |
| 338 } | 364 } |
| 339 | 365 |
| 340 | 366 |
| 341 void IC::PostPatching(Address address, Code* target, Code* old_target) { | 367 void IC::PostPatching(Address address, Code* target, Code* old_target) { |
| 342 Isolate* isolate = target->GetHeap()->isolate(); | 368 Isolate* isolate = target->GetHeap()->isolate(); |
| 343 Code* host = isolate-> | 369 Code* host = isolate-> |
| 344 inner_pointer_to_code_cache()->GetCacheEntry(address)->code; | 370 inner_pointer_to_code_cache()->GetCacheEntry(address)->code; |
| 345 if (host->kind() != Code::FUNCTION) return; | 371 if (host->kind() != Code::FUNCTION) return; |
| 346 | 372 |
| 347 if (FLAG_type_info_threshold > 0 && | 373 if (FLAG_type_info_threshold > 0 && old_target->is_inline_cache_stub() && |
| 348 old_target->is_inline_cache_stub() && | 374 target->is_inline_cache_stub() && |
| 349 target->is_inline_cache_stub()) { | 375 // Call ICs don't have interesting state changes from this point |
| 350 int delta = ComputeTypeInfoCountDelta(old_target->ic_state(), | 376 // of view. |
| 351 target->ic_state()); | 377 target->kind() != Code::CALL_IC && |
| 352 // Call ICs don't have interesting state changes from this point | 378 // Not all Code objects have TypeFeedbackInfo. |
| 353 // of view. | 379 host->type_feedback_info()->IsTypeFeedbackInfo()) { |
| 354 DCHECK(target->kind() != Code::CALL_IC || delta == 0); | 380 int polymorphic_delta = 0; // "Polymorphic" here includes monomorphic. |
| 355 | 381 int generic_delta = 0; // "Generic" here includes megamorphic. |
| 356 // Not all Code objects have TypeFeedbackInfo. | 382 ComputeTypeInfoCountDelta(old_target->ic_state(), target->ic_state(), |
| 357 if (host->type_feedback_info()->IsTypeFeedbackInfo() && delta != 0) { | 383 &polymorphic_delta, &generic_delta); |
| 358 TypeFeedbackInfo* info = | 384 TypeFeedbackInfo* info = TypeFeedbackInfo::cast(host->type_feedback_info()); |
| 359 TypeFeedbackInfo::cast(host->type_feedback_info()); | 385 info->change_ic_with_type_info_count(polymorphic_delta); |
| 360 info->change_ic_with_type_info_count(delta); | 386 info->change_ic_generic_count(generic_delta); |
| 361 } | |
| 362 } | 387 } |
| 363 if (host->type_feedback_info()->IsTypeFeedbackInfo()) { | 388 if (host->type_feedback_info()->IsTypeFeedbackInfo()) { |
| 364 TypeFeedbackInfo* info = | 389 TypeFeedbackInfo* info = |
| 365 TypeFeedbackInfo::cast(host->type_feedback_info()); | 390 TypeFeedbackInfo::cast(host->type_feedback_info()); |
| 366 info->change_own_type_change_checksum(); | 391 info->change_own_type_change_checksum(); |
| 367 } | 392 } |
| 368 host->set_profiler_ticks(0); | 393 host->set_profiler_ticks(0); |
| 369 isolate->runtime_profiler()->NotifyICChanged(); | 394 isolate->runtime_profiler()->NotifyICChanged(); |
| 370 // TODO(2029): When an optimized function is patched, it would | 395 // TODO(2029): When an optimized function is patched, it would |
| 371 // be nice to propagate the corresponding type information to its | 396 // be nice to propagate the corresponding type information to its |
| (...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3061 #undef ADDR | 3086 #undef ADDR |
| 3062 }; | 3087 }; |
| 3063 | 3088 |
| 3064 | 3089 |
| 3065 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3090 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3066 return IC_utilities[id]; | 3091 return IC_utilities[id]; |
| 3067 } | 3092 } |
| 3068 | 3093 |
| 3069 | 3094 |
| 3070 } } // namespace v8::internal | 3095 } } // namespace v8::internal |
| OLD | NEW |