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

Side by Side Diff: src/ic.h

Issue 458813002: Prototype implementation of GET_OWN_PROPERTY intrinsic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/ic.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 #ifndef V8_IC_H_ 5 #ifndef V8_IC_H_
6 #define V8_IC_H_ 6 #define V8_IC_H_
7 7
8 #include "src/macro-assembler.h" 8 #include "src/macro-assembler.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 static inline void SetTargetAtAddress(Address address, 177 static inline void SetTargetAtAddress(Address address,
178 Code* target, 178 Code* target,
179 ConstantPoolArray* constant_pool); 179 ConstantPoolArray* constant_pool);
180 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, 180 static void OnTypeFeedbackChanged(Isolate* isolate, Address address,
181 State old_state, State new_state, 181 State old_state, State new_state,
182 bool target_remains_ic_stub); 182 bool target_remains_ic_stub);
183 static void PostPatching(Address address, Code* target, Code* old_target); 183 static void PostPatching(Address address, Code* target, Code* old_target);
184 184
185 // Compute the handler either by compiling or by retrieving a cached version. 185 // Compute the handler either by compiling or by retrieving a cached version.
186 Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object, 186 Handle<Code> ComputeHandler(LookupIterator* lookup, Handle<Object> object,
187 Handle<String> name, 187 Handle<Name> name,
188 Handle<Object> value = Handle<Code>::null()); 188 Handle<Object> value = Handle<Code>::null());
189 virtual Handle<Code> CompileHandler(LookupIterator* lookup, 189 virtual Handle<Code> CompileHandler(LookupIterator* lookup,
190 Handle<Object> object, 190 Handle<Object> object,
191 Handle<String> name, Handle<Object> value, 191 Handle<Name> name, Handle<Object> value,
192 CacheHolderFlag cache_holder) { 192 CacheHolderFlag cache_holder) {
193 UNREACHABLE(); 193 UNREACHABLE();
194 return Handle<Code>::null(); 194 return Handle<Code>::null();
195 } 195 }
196 // Temporary copy of the above, but using a LookupResult. 196 // Temporary copy of the above, but using a LookupResult.
197 // TODO(jkummerow): Migrate callers to LookupIterator and delete these. 197 // TODO(jkummerow): Migrate callers to LookupIterator and delete these.
198 Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object, 198 Handle<Code> ComputeStoreHandler(LookupResult* lookup, Handle<Object> object,
199 Handle<String> name, 199 Handle<String> name,
200 Handle<Object> value = Handle<Code>::null()); 200 Handle<Object> value = Handle<Code>::null());
201 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup, 201 virtual Handle<Code> CompileStoreHandler(LookupResult* lookup,
202 Handle<Object> object, 202 Handle<Object> object,
203 Handle<String> name, 203 Handle<String> name,
204 Handle<Object> value, 204 Handle<Object> value,
205 CacheHolderFlag cache_holder) { 205 CacheHolderFlag cache_holder) {
206 UNREACHABLE(); 206 UNREACHABLE();
207 return Handle<Code>::null(); 207 return Handle<Code>::null();
208 } 208 }
209 209
210 void UpdateMonomorphicIC(Handle<Code> handler, Handle<String> name); 210 void UpdateMonomorphicIC(Handle<Code> handler, Handle<Name> name);
211 bool UpdatePolymorphicIC(Handle<String> name, Handle<Code> code); 211 bool UpdatePolymorphicIC(Handle<Name> name, Handle<Code> code);
212 void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code); 212 void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code);
213 213
214 void CopyICToMegamorphicCache(Handle<String> name); 214 void CopyICToMegamorphicCache(Handle<Name> name);
215 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map); 215 bool IsTransitionOfMonomorphicTarget(Map* source_map, Map* target_map);
216 void PatchCache(Handle<String> name, Handle<Code> code); 216 void PatchCache(Handle<Name> name, Handle<Code> code);
217 Code::Kind kind() const { return kind_; } 217 Code::Kind kind() const { return kind_; }
218 Code::Kind handler_kind() const { 218 Code::Kind handler_kind() const {
219 if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC; 219 if (kind_ == Code::KEYED_LOAD_IC) return Code::LOAD_IC;
220 DCHECK(kind_ == Code::LOAD_IC || kind_ == Code::STORE_IC || 220 DCHECK(kind_ == Code::LOAD_IC || kind_ == Code::STORE_IC ||
221 kind_ == Code::KEYED_STORE_IC); 221 kind_ == Code::KEYED_STORE_IC);
222 return kind_; 222 return kind_;
223 } 223 }
224 virtual Handle<Code> megamorphic_stub() { 224 virtual Handle<Code> megamorphic_stub() {
225 UNREACHABLE(); 225 UNREACHABLE();
226 return Handle<Code>::null(); 226 return Handle<Code>::null();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 OStream& operator<<(OStream& os, const CallIC::State& s); 391 OStream& operator<<(OStream& os, const CallIC::State& s);
392 392
393 393
394 class LoadIC: public IC { 394 class LoadIC: public IC {
395 public: 395 public:
396 enum ParameterIndices { 396 enum ParameterIndices {
397 kReceiverIndex, 397 kReceiverIndex,
398 kNameIndex, 398 kNameIndex,
399 kParameterCount 399 kParameterCount
400 }; 400 };
401 enum PropertyLookupMode {
402 NORMAL_LOOKUP,
403 OWN_PROPERTY_LOOKUP
404 };
401 static const Register ReceiverRegister(); 405 static const Register ReceiverRegister();
402 static const Register NameRegister(); 406 static const Register NameRegister();
403 407
404 // With flag vector-ics, there is an additional argument. And for calls from 408 // With flag vector-ics, there is an additional argument. And for calls from
405 // crankshaft, yet another. 409 // crankshaft, yet another.
406 static const Register SlotRegister(); 410 static const Register SlotRegister();
407 static const Register VectorRegister(); 411 static const Register VectorRegister();
408 412
409 class State V8_FINAL BASE_EMBEDDED { 413 class State V8_FINAL BASE_EMBEDDED {
410 public: 414 public:
411 explicit State(ExtraICState extra_ic_state) 415 explicit State(ExtraICState extra_ic_state)
412 : state_(extra_ic_state) {} 416 : state_(extra_ic_state) {}
413 417
414 explicit State(ContextualMode mode) 418 explicit State(
415 : state_(ContextualModeBits::encode(mode)) {} 419 ContextualMode contextual_mode,
420 PropertyLookupMode property_lookup_mode)
421 : state_(ContextualModeBits::encode(contextual_mode) |
422 PropertyLookupModeBits::encode(property_lookup_mode)) {}
416 423
417 ExtraICState GetExtraICState() const { return state_; } 424 ExtraICState GetExtraICState() const { return state_; }
418 425
419 ContextualMode contextual_mode() const { 426 ContextualMode contextual_mode() const {
420 return ContextualModeBits::decode(state_); 427 return ContextualModeBits::decode(state_);
421 } 428 }
422 429
430 PropertyLookupMode property_lookup_mode() const {
431 return PropertyLookupModeBits::decode(state_);
432 }
433
423 private: 434 private:
424 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; 435 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {};
436 class PropertyLookupModeBits: public BitField<PropertyLookupMode, 1, 1>{};
425 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); 437 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
438 STATIC_ASSERT(static_cast<int>(NORMAL_LOOKUP) == 0);
426 439
427 const ExtraICState state_; 440 const ExtraICState state_;
428 }; 441 };
429 442
430 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { 443 static ExtraICState ComputeExtraICState(
431 return State(contextual_mode).GetExtraICState(); 444 ContextualMode contextual_mode,
445 PropertyLookupMode property_lookup_mode) {
446 return State(contextual_mode, property_lookup_mode).GetExtraICState();
432 } 447 }
433 448
434 static ContextualMode GetContextualMode(ExtraICState state) { 449 static ContextualMode GetContextualMode(ExtraICState state) {
435 return State(state).contextual_mode(); 450 return State(state).contextual_mode();
436 } 451 }
437 452
453 static PropertyLookupMode GetPropertyLookupMode(ExtraICState state) {
454 return State(state).property_lookup_mode();
455 }
456
438 ContextualMode contextual_mode() const { 457 ContextualMode contextual_mode() const {
439 return GetContextualMode(extra_ic_state()); 458 return GetContextualMode(extra_ic_state());
440 } 459 }
441 460
461 PropertyLookupMode property_lookup_mode() const {
462 return GetPropertyLookupMode(extra_ic_state());
463 }
464
442 explicit LoadIC(FrameDepth depth, Isolate* isolate) 465 explicit LoadIC(FrameDepth depth, Isolate* isolate)
443 : IC(depth, isolate) { 466 : IC(depth, isolate) {
444 DCHECK(IsLoadStub()); 467 DCHECK(IsLoadStub());
445 } 468 }
446 469
447 // Returns if this IC is for contextual (no explicit receiver) 470 // Returns if this IC is for contextual (no explicit receiver)
448 // access to properties. 471 // access to properties.
449 bool IsUndeclaredGlobal(Handle<Object> receiver) { 472 bool IsUndeclaredGlobal(Handle<Object> receiver) {
450 if (receiver->IsGlobalObject()) { 473 if (receiver->IsGlobalObject()) {
451 return contextual_mode() == CONTEXTUAL; 474 return contextual_mode() == CONTEXTUAL;
452 } else { 475 } else {
453 DCHECK(contextual_mode() != CONTEXTUAL); 476 DCHECK(contextual_mode() != CONTEXTUAL);
454 return false; 477 return false;
455 } 478 }
456 } 479 }
457 480
458 // Code generator routines. 481 // Code generator routines.
459 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 482 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
460 static void GeneratePreMonomorphic(MacroAssembler* masm) { 483 static void GeneratePreMonomorphic(MacroAssembler* masm) {
461 GenerateMiss(masm); 484 GenerateMiss(masm);
462 } 485 }
463 static void GenerateMiss(MacroAssembler* masm); 486 static void GenerateMiss(MacroAssembler* masm);
464 static void GenerateMegamorphic(MacroAssembler* masm); 487 static void GenerateMegamorphic(MacroAssembler* masm, ExtraICState extra_ic_st ate);
465 static void GenerateNormal(MacroAssembler* masm); 488 static void GenerateNormal(MacroAssembler* masm);
466 static void GenerateRuntimeGetProperty(MacroAssembler* masm); 489 static void GenerateRuntimeGetProperty(MacroAssembler* masm);
490 static void GenerateRuntimeGetOwnProperty(MacroAssembler* masm);
467 491
468 static Handle<Code> initialize_stub(Isolate* isolate, 492 static Handle<Code> initialize_stub(Isolate* isolate,
469 ExtraICState extra_state); 493 ExtraICState extra_state);
470 494
471 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, 495 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
472 Handle<String> name); 496 Handle<Name> name);
473 497
474 protected: 498 protected:
475 void set_target(Code* code) { 499 void set_target(Code* code) {
476 // The contextual mode must be preserved across IC patching. 500 // The contextual mode and the property lookup mode
501 // must be preserved across IC patching.
477 DCHECK(GetContextualMode(code->extra_ic_state()) == 502 DCHECK(GetContextualMode(code->extra_ic_state()) ==
478 GetContextualMode(target()->extra_ic_state())); 503 GetContextualMode(target()->extra_ic_state()));
504 DCHECK(GetPropertyLookupMode(code->extra_ic_state()) ==
505 GetPropertyLookupMode(target()->extra_ic_state()));
479 506
480 IC::set_target(code); 507 IC::set_target(code);
481 } 508 }
482 509
483 Handle<Code> slow_stub() const { 510 Handle<Code> slow_stub() const {
484 if (kind() == Code::LOAD_IC) { 511 if (kind() == Code::LOAD_IC) {
485 return isolate()->builtins()->LoadIC_Slow(); 512 if (property_lookup_mode() == OWN_PROPERTY_LOOKUP) {
513 return isolate()->builtins()->LoadICOwn_Slow();
514 } else {
515 return isolate()->builtins()->LoadIC_Slow();
516 }
486 } else { 517 } else {
487 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); 518 DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
488 return isolate()->builtins()->KeyedLoadIC_Slow(); 519 if (property_lookup_mode() == OWN_PROPERTY_LOOKUP) {
520 return isolate()->builtins()->KeyedLoadICOwn_Slow();
521 } else {
522 return isolate()->builtins()->KeyedLoadIC_Slow();
523 }
489 } 524 }
490 } 525 }
491 526
492 virtual Handle<Code> megamorphic_stub(); 527 virtual Handle<Code> megamorphic_stub() V8_OVERRIDE;
493 528
494 // Update the inline cache and the global stub cache based on the 529 // Update the inline cache and the global stub cache based on the
495 // lookup result. 530 // lookup result.
496 void UpdateCaches(LookupIterator* lookup, Handle<Object> object, 531 void UpdateCaches(LookupIterator* lookup, Handle<Object> object,
497 Handle<String> name); 532 Handle<Name> name);
498 533
499 virtual Handle<Code> CompileHandler(LookupIterator* lookup, 534 virtual Handle<Code> CompileHandler(LookupIterator* lookup,
500 Handle<Object> object, 535 Handle<Object> object,
501 Handle<String> name, 536 Handle<Name> name,
502 Handle<Object> unused, 537 Handle<Object> unused,
503 CacheHolderFlag cache_holder); 538 CacheHolderFlag cache_holder);
504 539
505 private: 540 private:
506 virtual Handle<Code> pre_monomorphic_stub() const; 541 virtual Handle<Code> pre_monomorphic_stub() V8_OVERRIDE const;
507 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, 542 static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
508 ExtraICState extra_state); 543 ExtraICState extra_state);
509 544
510 Handle<Code> SimpleFieldLoad(FieldIndex index); 545 Handle<Code> SimpleFieldLoad(FieldIndex index);
511 546
512 static void Clear(Isolate* isolate, 547 static void Clear(Isolate* isolate,
513 Address address, 548 Address address,
514 Code* target, 549 Code* target,
515 ConstantPoolArray* constant_pool); 550 ConstantPoolArray* constant_pool);
516 551
517 friend class IC; 552 friend class IC;
518 }; 553 };
519 554
520 555
521 class KeyedLoadIC: public LoadIC { 556 class KeyedLoadIC: public LoadIC {
522 public: 557 public:
523 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) 558 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate)
524 : LoadIC(depth, isolate) { 559 : LoadIC(depth, isolate) {
525 DCHECK(target()->is_keyed_load_stub()); 560 DCHECK(target()->is_keyed_load_stub());
526 } 561 }
527 562
528 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, 563 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
529 Handle<Object> key); 564 Handle<Object> key);
530 565
531 // Code generator routines. 566 // Code generator routines.
532 static void GenerateMiss(MacroAssembler* masm); 567 static void GenerateMiss(MacroAssembler* masm);
533 static void GenerateRuntimeGetProperty(MacroAssembler* masm); 568 static void GenerateRuntimeGetProperty(MacroAssembler* masm);
569 static void GenerateRuntimeGetOwnProperty(MacroAssembler* masm);
534 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 570 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
535 static void GeneratePreMonomorphic(MacroAssembler* masm) { 571 static void GeneratePreMonomorphic(MacroAssembler* masm) {
536 GenerateMiss(masm); 572 GenerateMiss(masm);
537 } 573 }
538 static void GenerateGeneric(MacroAssembler* masm); 574 static void GenerateGeneric(MacroAssembler* masm, ExtraICState extra_state);
539 static void GenerateString(MacroAssembler* masm); 575 static void GenerateString(MacroAssembler* masm);
540 static void GenerateIndexedInterceptor(MacroAssembler* masm); 576 static void GenerateIndexedInterceptor(MacroAssembler* masm);
541 static void GenerateSloppyArguments(MacroAssembler* masm); 577 static void GenerateSloppyArguments(MacroAssembler* masm);
542 578
543 // Bit mask to be tested against bit field for the cases when 579 // Bit mask to be tested against bit field for the cases when
544 // generic stub should go into slow case. 580 // generic stub should go into slow case.
545 // Access check is necessary explicitly since generic stub does not perform 581 // Access check is necessary explicitly since generic stub does not perform
546 // map checks. 582 // map checks.
547 static const int kSlowCaseBitFieldMask = 583 static const int kSlowCaseBitFieldMask =
548 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); 584 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor);
549 585
550 static Handle<Code> generic_stub(Isolate* isolate); 586 static Handle<Code> initialize_stub(Isolate* isolate,
551 static Handle<Code> pre_monomorphic_stub(Isolate* isolate); 587 ExtraICState extra_state);
588 static Handle<Code> generic_stub(Isolate* isolate,
589 ExtraICState extra_state);
590 static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
591 ExtraICState extra_state);
552 592
553 protected: 593 protected:
554 Handle<Code> LoadElementStub(Handle<JSObject> receiver); 594 Handle<Code> LoadElementStub(Handle<JSObject> receiver);
555 virtual Handle<Code> pre_monomorphic_stub() const { 595 virtual Handle<Code> pre_monomorphic_stub() const {
556 return pre_monomorphic_stub(isolate()); 596 return pre_monomorphic_stub(isolate(), extra_ic_state());
557 } 597 }
558 598
559 private: 599 private:
560 Handle<Code> generic_stub() const { return generic_stub(isolate()); } 600 Handle<Code> generic_stub() const { return generic_stub(isolate(), extra_ic_st ate()); }
561 Handle<Code> indexed_interceptor_stub() { 601 Handle<Code> indexed_interceptor_stub() {
602 DCHECK(GetPropertyLookupMode(extra_ic_state()) == NORMAL_LOOKUP);
562 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); 603 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor();
563 } 604 }
564 Handle<Code> sloppy_arguments_stub() { 605 Handle<Code> sloppy_arguments_stub() {
606 DCHECK(GetPropertyLookupMode(extra_ic_state()) == NORMAL_LOOKUP);
565 return isolate()->builtins()->KeyedLoadIC_SloppyArguments(); 607 return isolate()->builtins()->KeyedLoadIC_SloppyArguments();
566 } 608 }
567 Handle<Code> string_stub() { 609 Handle<Code> string_stub() {
610 DCHECK(GetPropertyLookupMode(extra_ic_state()) == NORMAL_LOOKUP);
568 return isolate()->builtins()->KeyedLoadIC_String(); 611 return isolate()->builtins()->KeyedLoadIC_String();
569 } 612 }
570 613
571 static void Clear(Isolate* isolate, 614 static void Clear(Isolate* isolate,
572 Address address, 615 Address address,
573 Code* target, 616 Code* target,
574 ConstantPoolArray* constant_pool); 617 ConstantPoolArray* constant_pool);
575 618
576 friend class IC; 619 friend class IC;
577 }; 620 };
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); 1083 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss);
1041 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); 1084 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss);
1042 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); 1085 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite);
1043 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); 1086 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss);
1044 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); 1087 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss);
1045 1088
1046 1089
1047 } } // namespace v8::internal 1090 } } // namespace v8::internal
1048 1091
1049 #endif // V8_IC_H_ 1092 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698