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...) 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...) 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...) 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...) 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 ContextualMode mode = IC::GetContextualMode(target->extra_ic_state()); |
508 Code* code = | 497 Code* code = target->GetIsolate()->stub_cache()->FindCallInitialize( |
509 target->GetIsolate()->stub_cache()->FindCallInitialize( | 498 target->arguments_count(), mode, target->kind()); |
510 target->arguments_count(), | |
511 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, | |
512 target->kind()); | |
513 SetTargetAtAddress(address, code); | 499 SetTargetAtAddress(address, code); |
514 } | 500 } |
515 | 501 |
516 | 502 |
517 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target) { | 503 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
518 if (IsCleared(target)) return; | 504 if (IsCleared(target)) return; |
519 // Make sure to also clear the map used in inline fast cases. If we | 505 // 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 | 506 // do not clear these maps, cached code can keep objects alive |
521 // through the embedded maps. | 507 // through the embedded maps. |
522 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); | 508 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); |
523 } | 509 } |
524 | 510 |
525 | 511 |
526 void LoadIC::Clear(Isolate* isolate, Address address, Code* target) { | 512 void LoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
527 if (IsCleared(target)) return; | 513 if (IsCleared(target)) return; |
528 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate)); | 514 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( |
| 515 Code::LOAD_IC, target->extra_ic_state()); |
| 516 SetTargetAtAddress(address, code); |
529 } | 517 } |
530 | 518 |
531 | 519 |
532 void StoreIC::Clear(Isolate* isolate, Address address, Code* target) { | 520 void StoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
533 if (IsCleared(target)) return; | 521 if (IsCleared(target)) return; |
534 SetTargetAtAddress(address, | 522 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( |
535 *pre_monomorphic_stub( | 523 Code::STORE_IC, target->extra_ic_state()); |
536 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); | 524 SetTargetAtAddress(address, code); |
537 } | 525 } |
538 | 526 |
539 | 527 |
540 void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target) { | 528 void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
541 if (IsCleared(target)) return; | 529 if (IsCleared(target)) return; |
542 SetTargetAtAddress(address, | 530 SetTargetAtAddress(address, |
543 *pre_monomorphic_stub( | 531 *pre_monomorphic_stub( |
544 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); | 532 isolate, StoreIC::GetStrictMode(target->extra_ic_state()))); |
545 } | 533 } |
546 | 534 |
(...skipping 563 matching lines...) Loading... |
1110 break; | 1098 break; |
1111 case DEBUG_STUB: | 1099 case DEBUG_STUB: |
1112 break; | 1100 break; |
1113 case GENERIC: | 1101 case GENERIC: |
1114 UNREACHABLE(); | 1102 UNREACHABLE(); |
1115 break; | 1103 break; |
1116 } | 1104 } |
1117 } | 1105 } |
1118 | 1106 |
1119 | 1107 |
| 1108 Handle<Code> LoadIC::initialize_stub(Isolate* isolate, ContextualMode mode) { |
| 1109 Handle<Code> ic = isolate->stub_cache()->ComputeLoad( |
| 1110 UNINITIALIZED, IC::ComputeExtraICState(mode)); |
| 1111 return ic; |
| 1112 } |
| 1113 |
| 1114 |
| 1115 Handle<Code> LoadIC::pre_monomorphic_stub(Isolate* isolate, |
| 1116 ContextualMode mode) { |
| 1117 return isolate->stub_cache()->ComputeLoad( |
| 1118 PREMONOMORPHIC, IC::ComputeExtraICState(mode)); |
| 1119 } |
| 1120 |
| 1121 |
| 1122 Handle<Code> LoadIC::megamorphic_stub() { |
| 1123 return isolate()->stub_cache()->ComputeLoad( |
| 1124 MEGAMORPHIC, extra_ic_state()); |
| 1125 } |
| 1126 |
| 1127 |
1120 Handle<Code> LoadIC::SimpleFieldLoad(int offset, | 1128 Handle<Code> LoadIC::SimpleFieldLoad(int offset, |
1121 bool inobject, | 1129 bool inobject, |
1122 Representation representation) { | 1130 Representation representation) { |
1123 if (kind() == Code::LOAD_IC) { | 1131 if (kind() == Code::LOAD_IC) { |
1124 LoadFieldStub stub(inobject, offset, representation); | 1132 LoadFieldStub stub(inobject, offset, representation); |
1125 return stub.GetCode(isolate()); | 1133 return stub.GetCode(isolate()); |
1126 } else { | 1134 } else { |
1127 KeyedLoadFieldStub stub(inobject, offset, representation); | 1135 KeyedLoadFieldStub stub(inobject, offset, representation); |
1128 return stub.GetCode(isolate()); | 1136 return stub.GetCode(isolate()); |
1129 } | 1137 } |
(...skipping 457 matching lines...) Loading... |
1587 } | 1595 } |
1588 | 1596 |
1589 // Set the property. | 1597 // Set the property. |
1590 Handle<Object> result = JSReceiver::SetProperty( | 1598 Handle<Object> result = JSReceiver::SetProperty( |
1591 receiver, name, value, NONE, strict_mode(), store_mode); | 1599 receiver, name, value, NONE, strict_mode(), store_mode); |
1592 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 1600 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
1593 return *result; | 1601 return *result; |
1594 } | 1602 } |
1595 | 1603 |
1596 | 1604 |
| 1605 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, |
| 1606 StrictModeFlag strict_mode, |
| 1607 ContextualMode mode) { |
| 1608 ExtraICState extra_state = ComputeExtraICState(strict_mode, mode); |
| 1609 Handle<Code> ic = isolate->stub_cache()->ComputeStore( |
| 1610 UNINITIALIZED, extra_state); |
| 1611 return ic; |
| 1612 } |
| 1613 |
| 1614 |
| 1615 Handle<Code> StoreIC::megamorphic_stub() { |
| 1616 return isolate()->stub_cache()->ComputeStore(MEGAMORPHIC, extra_ic_state()); |
| 1617 } |
| 1618 |
| 1619 |
| 1620 Handle<Code> StoreIC::generic_stub() const { |
| 1621 return isolate()->stub_cache()->ComputeStore(GENERIC, extra_ic_state()); |
| 1622 } |
| 1623 |
| 1624 |
| 1625 Handle<Code> StoreIC::pre_monomorphic_stub(Isolate* isolate, |
| 1626 StrictModeFlag strict_mode, |
| 1627 ContextualMode contextual_mode) { |
| 1628 ExtraICState state = StoreIC::ComputeExtraICState(strict_mode, |
| 1629 contextual_mode); |
| 1630 return isolate->stub_cache()->ComputeStore(PREMONOMORPHIC, state); |
| 1631 } |
| 1632 |
| 1633 |
1597 void StoreIC::UpdateCaches(LookupResult* lookup, | 1634 void StoreIC::UpdateCaches(LookupResult* lookup, |
1598 Handle<JSObject> receiver, | 1635 Handle<JSObject> receiver, |
1599 Handle<String> name, | 1636 Handle<String> name, |
1600 Handle<Object> value) { | 1637 Handle<Object> value) { |
1601 ASSERT(lookup->IsFound()); | 1638 ASSERT(lookup->IsFound()); |
1602 | 1639 |
1603 // These are not cacheable, so we never see such LookupResults here. | 1640 // These are not cacheable, so we never see such LookupResults here. |
1604 ASSERT(!lookup->IsHandler()); | 1641 ASSERT(!lookup->IsHandler()); |
1605 | 1642 |
1606 Handle<Code> code = ComputeHandler(lookup, receiver, name, value); | 1643 Handle<Code> code = ComputeHandler(lookup, receiver, name, value); |
(...skipping 1536 matching lines...) Loading... |
3143 #undef ADDR | 3180 #undef ADDR |
3144 }; | 3181 }; |
3145 | 3182 |
3146 | 3183 |
3147 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3184 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3148 return IC_utilities[id]; | 3185 return IC_utilities[id]; |
3149 } | 3186 } |
3150 | 3187 |
3151 | 3188 |
3152 } } // namespace v8::internal | 3189 } } // namespace v8::internal |
OLD | NEW |