| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 #ifdef DEBUG | 140 #ifdef DEBUG |
| 141 StackFrameIterator it(isolate); | 141 StackFrameIterator it(isolate); |
| 142 for (int i = 0; i < depth + 1; i++) it.Advance(); | 142 for (int i = 0; i < depth + 1; i++) it.Advance(); |
| 143 StackFrame* frame = it.frame(); | 143 StackFrame* frame = it.frame(); |
| 144 ASSERT(fp == frame->fp() && pc_address == frame->pc_address()); | 144 ASSERT(fp == frame->fp() && pc_address == frame->pc_address()); |
| 145 #endif | 145 #endif |
| 146 fp_ = fp; | 146 fp_ = fp; |
| 147 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address); | 147 pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address); |
| 148 target_ = handle(raw_target(), isolate); | 148 target_ = handle(raw_target(), isolate); |
| 149 state_ = target_->ic_state(); | 149 state_ = target_->ic_state(); |
| 150 extra_ic_state_ = target_->needs_extended_extra_ic_state(target_->kind()) |
| 151 ? target_->extended_extra_ic_state() |
| 152 : target_->extra_ic_state(); |
| 150 } | 153 } |
| 151 | 154 |
| 152 | 155 |
| 153 #ifdef ENABLE_DEBUGGER_SUPPORT | 156 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 154 Address IC::OriginalCodeAddress() const { | 157 Address IC::OriginalCodeAddress() const { |
| 155 HandleScope scope(isolate()); | 158 HandleScope scope(isolate()); |
| 156 // Compute the JavaScript frame for the frame pointer of this IC | 159 // Compute the JavaScript frame for the frame pointer of this IC |
| 157 // structure. We need this to be able to find the function | 160 // structure. We need this to be able to find the function |
| 158 // corresponding to the frame. | 161 // corresponding to the frame. |
| 159 StackFrameIterator it(isolate()); | 162 StackFrameIterator it(isolate()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 if (object->IsString()) { | 250 if (object->IsString()) { |
| 248 String* string = String::cast(*object); | 251 String* string = String::cast(*object); |
| 249 // Check there's the right string value or wrapper in the receiver slot. | 252 // Check there's the right string value or wrapper in the receiver slot. |
| 250 ASSERT(string == args[0] || string == JSValue::cast(args[0])->value()); | 253 ASSERT(string == args[0] || string == JSValue::cast(args[0])->value()); |
| 251 // If we're in the default (fastest) state and the index is | 254 // If we're in the default (fastest) state and the index is |
| 252 // out of bounds, update the state to record this fact. | 255 // out of bounds, update the state to record this fact. |
| 253 if (StringStubState::decode(extra_ic_state()) == DEFAULT_STRING_STUB && | 256 if (StringStubState::decode(extra_ic_state()) == DEFAULT_STRING_STUB && |
| 254 argc >= 1 && args[1]->IsNumber()) { | 257 argc >= 1 && args[1]->IsNumber()) { |
| 255 double index = DoubleToInteger(args.number_at(1)); | 258 double index = DoubleToInteger(args.number_at(1)); |
| 256 if (index < 0 || index >= string->length()) { | 259 if (index < 0 || index >= string->length()) { |
| 257 extra_ic_state_ = | 260 set_extra_ic_state(StringStubState::update(extra_ic_state(), |
| 258 StringStubState::update(extra_ic_state(), | 261 STRING_INDEX_OUT_OF_BOUNDS)); |
| 259 STRING_INDEX_OUT_OF_BOUNDS); | |
| 260 return true; | 262 return true; |
| 261 } | 263 } |
| 262 } | 264 } |
| 263 } | 265 } |
| 264 break; | 266 break; |
| 265 default: | 267 default: |
| 266 return false; | 268 return false; |
| 267 } | 269 } |
| 268 return false; | 270 return false; |
| 269 } | 271 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // The builtins object is special. It only changes when JavaScript | 392 // The builtins object is special. It only changes when JavaScript |
| 391 // builtins are loaded lazily. It is important to keep inline | 393 // builtins are loaded lazily. It is important to keep inline |
| 392 // caches for the builtins object monomorphic. Therefore, if we get | 394 // caches for the builtins object monomorphic. Therefore, if we get |
| 393 // an inline cache miss for the builtins object after lazily loading | 395 // an inline cache miss for the builtins object after lazily loading |
| 394 // JavaScript builtins, we return uninitialized as the state to | 396 // JavaScript builtins, we return uninitialized as the state to |
| 395 // force the inline cache back to monomorphic state. | 397 // force the inline cache back to monomorphic state. |
| 396 if (receiver->IsJSBuiltinsObject()) state_ = UNINITIALIZED; | 398 if (receiver->IsJSBuiltinsObject()) state_ = UNINITIALIZED; |
| 397 } | 399 } |
| 398 | 400 |
| 399 | 401 |
| 400 RelocInfo::Mode IC::ComputeMode() { | |
| 401 Address addr = address(); | |
| 402 Code* code = Code::cast(isolate()->FindCodeObject(addr)); | |
| 403 for (RelocIterator it(code, RelocInfo::kCodeTargetMask); | |
| 404 !it.done(); it.next()) { | |
| 405 RelocInfo* info = it.rinfo(); | |
| 406 if (info->pc() == addr) return info->rmode(); | |
| 407 } | |
| 408 UNREACHABLE(); | |
| 409 return RelocInfo::NONE32; | |
| 410 } | |
| 411 | |
| 412 | |
| 413 Failure* IC::TypeError(const char* type, | 402 Failure* IC::TypeError(const char* type, |
| 414 Handle<Object> object, | 403 Handle<Object> object, |
| 415 Handle<Object> key) { | 404 Handle<Object> key) { |
| 416 HandleScope scope(isolate()); | 405 HandleScope scope(isolate()); |
| 417 Handle<Object> args[2] = { key, object }; | 406 Handle<Object> args[2] = { key, object }; |
| 418 Handle<Object> error = isolate()->factory()->NewTypeError( | 407 Handle<Object> error = isolate()->factory()->NewTypeError( |
| 419 type, HandleVector(args, 2)); | 408 type, HandleVector(args, 2)); |
| 420 return isolate()->Throw(*error); | 409 return isolate()->Throw(*error); |
| 421 } | 410 } |
| 422 | 411 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // Clearing these is tricky and does not | 486 // Clearing these is tricky and does not |
| 498 // make any performance difference. | 487 // make any performance difference. |
| 499 return; | 488 return; |
| 500 default: UNREACHABLE(); | 489 default: UNREACHABLE(); |
| 501 } | 490 } |
| 502 } | 491 } |
| 503 | 492 |
| 504 | 493 |
| 505 void CallICBase::Clear(Address address, Code* target) { | 494 void CallICBase::Clear(Address address, Code* target) { |
| 506 if (IsCleared(target)) return; | 495 if (IsCleared(target)) return; |
| 507 bool contextual = CallICBase::Contextual::decode(target->extra_ic_state()); | 496 // Is the site contextual or not? |
| 497 ContextualMode mode = IC::GetContextualMode(target->extra_ic_state()); |
| 508 Code* code = | 498 Code* code = |
| 509 target->GetIsolate()->stub_cache()->FindCallInitialize( | 499 target->GetIsolate()->stub_cache()->FindCallInitialize( |
| 510 target->arguments_count(), | 500 target->arguments_count(), |
| 511 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, | 501 mode, |
| 512 target->kind()); | 502 target->kind()); |
| 513 SetTargetAtAddress(address, code); | 503 SetTargetAtAddress(address, code); |
| 514 } | 504 } |
| 515 | 505 |
| 516 | 506 |
| 517 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target) { | 507 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
| 518 if (IsCleared(target)) return; | 508 if (IsCleared(target)) return; |
| 519 // Make sure to also clear the map used in inline fast cases. If we | 509 // Make sure to also clear the map used in inline fast cases. If we |
| 520 // do not clear these maps, cached code can keep objects alive | 510 // do not clear these maps, cached code can keep objects alive |
| 521 // through the embedded maps. | 511 // through the embedded maps. |
| 522 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); | 512 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); |
| 523 } | 513 } |
| 524 | 514 |
| 525 | 515 |
| 526 void LoadIC::Clear(Isolate* isolate, Address address, Code* target) { | 516 void LoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
| 527 if (IsCleared(target)) return; | 517 if (IsCleared(target)) return; |
| 528 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); | 518 ContextualMode mode = IC::GetContextualMode(target->extra_ic_state()); |
| 519 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate, mode)); |
| 529 } | 520 } |
| 530 | 521 |
| 531 | 522 |
| 532 void StoreIC::Clear(Isolate* isolate, Address address, Code* target) { | 523 void StoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
| 533 if (IsCleared(target)) return; | 524 if (IsCleared(target)) return; |
| 534 SetTargetAtAddress(address, | 525 SetTargetAtAddress(address, |
| 535 *pre_monomorphic_stub( | 526 *pre_monomorphic_stub( |
| 536 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); | 527 isolate, StoreIC::GetStrictMode(target->extra_ic_state()), |
| 528 IC::GetContextualMode(target->extra_ic_state()))); |
| 537 } | 529 } |
| 538 | 530 |
| 539 | 531 |
| 540 void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target) { | 532 void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
| 541 if (IsCleared(target)) return; | 533 if (IsCleared(target)) return; |
| 542 SetTargetAtAddress(address, | 534 SetTargetAtAddress(address, |
| 543 *pre_monomorphic_stub( | 535 *pre_monomorphic_stub( |
| 544 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); | 536 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); |
| 545 } | 537 } |
| 546 | 538 |
| (...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 #undef ADDR | 2747 #undef ADDR |
| 2756 }; | 2748 }; |
| 2757 | 2749 |
| 2758 | 2750 |
| 2759 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2751 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2760 return IC_utilities[id]; | 2752 return IC_utilities[id]; |
| 2761 } | 2753 } |
| 2762 | 2754 |
| 2763 | 2755 |
| 2764 } } // namespace v8::internal | 2756 } } // namespace v8::internal |
| OLD | NEW |