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

Side by Side Diff: src/ic.h

Issue 143633007: A64: Synchronize with r18764. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/stub-cache-ia32.cc ('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 // 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Alias the inline cache state type to make the IC code more readable. 82 // Alias the inline cache state type to make the IC code more readable.
83 typedef InlineCacheState State; 83 typedef InlineCacheState State;
84 84
85 // The IC code is either invoked with no extra frames on the stack 85 // The IC code is either invoked with no extra frames on the stack
86 // or with a single extra frame for supporting calls. 86 // or with a single extra frame for supporting calls.
87 enum FrameDepth { 87 enum FrameDepth {
88 NO_EXTRA_FRAME = 0, 88 NO_EXTRA_FRAME = 0,
89 EXTRA_CALL_FRAME = 1 89 EXTRA_CALL_FRAME = 1
90 }; 90 };
91 91
92 // ExtraICState shared by all ICs.
93 class Contextual: public BitField<ContextualMode, 0, 1> {};
94 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
95 static ExtraICState ComputeExtraICState(ContextualMode mode) {
96 return Contextual::encode(mode);
97 }
98
99 static ContextualMode GetContextualMode(ExtraICState state) {
100 return Contextual::decode(state);
101 }
102
103 static const ExtraICState kContextualState =
104 static_cast<int>(CONTEXTUAL) << Contextual::kShift;
105
106 // Construct the IC structure with the given number of extra 92 // Construct the IC structure with the given number of extra
107 // JavaScript frames on the stack. 93 // JavaScript frames on the stack.
108 IC(FrameDepth depth, Isolate* isolate); 94 IC(FrameDepth depth, Isolate* isolate);
109 virtual ~IC() {} 95 virtual ~IC() {}
110 96
111 State state() const { return state_; } 97 State state() const { return state_; }
112 inline Address address() const; 98 inline Address address() const;
113 99
114 // Compute the current IC state based on the target stub, receiver and name. 100 // Compute the current IC state based on the target stub, receiver and name.
115 void UpdateState(Handle<Object> receiver, Handle<Object> name); 101 void UpdateState(Handle<Object> receiver, Handle<Object> name);
116 void MarkMonomorphicPrototypeFailure() { 102 void MarkMonomorphicPrototypeFailure() {
117 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; 103 state_ = MONOMORPHIC_PROTOTYPE_FAILURE;
118 } 104 }
119 105
120 // Clear the inline cache to initial state. 106 // Clear the inline cache to initial state.
121 static void Clear(Isolate* isolate, Address address); 107 static void Clear(Isolate* isolate, Address address);
122 108
123 // Returns if this IC is for contextual (no explicit receiver)
124 // access to properties.
125 bool IsUndeclaredGlobal(Handle<Object> receiver) {
126 if (receiver->IsGlobalObject()) {
127 return IsCallStub() || IsContextual();
128 } else {
129 ASSERT(!IsContextual());
130 return false;
131 }
132 }
133
134 #ifdef DEBUG 109 #ifdef DEBUG
135 bool IsLoadStub() { 110 bool IsLoadStub() const {
136 return target()->is_load_stub() || target()->is_keyed_load_stub(); 111 return target()->is_load_stub() || target()->is_keyed_load_stub();
137 } 112 }
138 113
139 bool IsStoreStub() { 114 bool IsStoreStub() const {
140 return target()->is_store_stub() || target()->is_keyed_store_stub(); 115 return target()->is_store_stub() || target()->is_keyed_store_stub();
141 } 116 }
142 117
143 #endif 118 bool IsCallStub() const {
144 bool IsCallStub() {
145 return target()->is_call_stub() || target()->is_keyed_call_stub(); 119 return target()->is_call_stub() || target()->is_keyed_call_stub();
146 } 120 }
121 #endif
147 122
148 // Determines which map must be used for keeping the code stub. 123 // Determines which map must be used for keeping the code stub.
149 // These methods should not be called with undefined or null. 124 // These methods should not be called with undefined or null.
150 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); 125 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object);
151 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* 126 // TODO(verwaest): This currently returns a HeapObject rather than JSObject*
152 // since loading the IC for loading the length from strings are stored on 127 // since loading the IC for loading the length from strings are stored on
153 // the string map directly, rather than on the JSObject-typed prototype. 128 // the string map directly, rather than on the JSObject-typed prototype.
154 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, 129 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate,
155 Object* object, 130 Object* object,
156 InlineCacheHolderFlag holder); 131 InlineCacheHolderFlag holder);
157 132
158 static inline InlineCacheHolderFlag GetCodeCacheFlag(Type* type); 133 static inline InlineCacheHolderFlag GetCodeCacheFlag(HeapType* type);
159 static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag, 134 static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag,
160 Type* type, 135 HeapType* type,
161 Isolate* isolate); 136 Isolate* isolate);
162 137
163 static bool IsCleared(Code* code) { 138 static bool IsCleared(Code* code) {
164 InlineCacheState state = code->ic_state(); 139 InlineCacheState state = code->ic_state();
165 return state == UNINITIALIZED || state == PREMONOMORPHIC; 140 return state == UNINITIALIZED || state == PREMONOMORPHIC;
166 } 141 }
167 142
168 // Utility functions to convert maps to types and back. There are two special 143 // Utility functions to convert maps to types and back. There are two special
169 // cases: 144 // cases:
170 // - The heap_number_map is used as a marker which includes heap numbers as 145 // - The heap_number_map is used as a marker which includes heap numbers as
171 // well as smis. 146 // well as smis.
172 // - The oddball map is only used for booleans. 147 // - The oddball map is only used for booleans.
173 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); 148 static Handle<Map> TypeToMap(HeapType* type, Isolate* isolate);
174 static Handle<Type> MapToType(Handle<Map> type); 149 static Handle<HeapType> MapToType(Handle<Map> map);
175 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); 150 static Handle<HeapType> CurrentTypeOf(
176 151 Handle<Object> object, Isolate* isolate);
177 ContextualMode contextual_mode() const {
178 return Contextual::decode(extra_ic_state());
179 }
180
181 bool IsContextual() const { return contextual_mode() == CONTEXTUAL; }
182 152
183 protected: 153 protected:
184 // Get the call-site target; used for determining the state. 154 // Get the call-site target; used for determining the state.
185 Handle<Code> target() const { return target_; } 155 Handle<Code> target() const { return target_; }
186 156
187 Address fp() const { return fp_; } 157 Address fp() const { return fp_; }
188 Address pc() const { return *pc_address_; } 158 Address pc() const { return *pc_address_; }
189 Isolate* isolate() const { return isolate_; } 159 Isolate* isolate() const { return isolate_; }
190 160
191 #ifdef ENABLE_DEBUGGER_SUPPORT 161 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 Handle<Object> value = Handle<Code>::null()); 195 Handle<Object> value = Handle<Code>::null());
226 virtual Handle<Code> CompileHandler(LookupResult* lookup, 196 virtual Handle<Code> CompileHandler(LookupResult* lookup,
227 Handle<Object> object, 197 Handle<Object> object,
228 Handle<String> name, 198 Handle<String> name,
229 Handle<Object> value, 199 Handle<Object> value,
230 InlineCacheHolderFlag cache_holder) { 200 InlineCacheHolderFlag cache_holder) {
231 UNREACHABLE(); 201 UNREACHABLE();
232 return Handle<Code>::null(); 202 return Handle<Code>::null();
233 } 203 }
234 204
235 void UpdateMonomorphicIC(Handle<Type> type, 205 void UpdateMonomorphicIC(Handle<HeapType> type,
236 Handle<Code> handler, 206 Handle<Code> handler,
237 Handle<String> name); 207 Handle<String> name);
238 208
239 bool UpdatePolymorphicIC(Handle<Type> type, 209 bool UpdatePolymorphicIC(Handle<HeapType> type,
240 Handle<String> name, 210 Handle<String> name,
241 Handle<Code> code); 211 Handle<Code> code);
242 212
243 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code); 213 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code);
244 214
245 void CopyICToMegamorphicCache(Handle<String> name); 215 void CopyICToMegamorphicCache(Handle<String> name);
246 bool IsTransitionOfMonomorphicTarget(Handle<Type> type); 216 bool IsTransitionOfMonomorphicTarget(Handle<HeapType> type);
247 void PatchCache(Handle<Type> type, 217 void PatchCache(Handle<HeapType> type,
248 Handle<String> name, 218 Handle<String> name,
249 Handle<Code> code); 219 Handle<Code> code);
250 virtual Code::Kind kind() const { 220 virtual Code::Kind kind() const {
251 UNREACHABLE(); 221 UNREACHABLE();
252 return Code::STUB; 222 return Code::STUB;
253 } 223 }
254 virtual Handle<Code> slow_stub() const { 224 virtual Handle<Code> slow_stub() const {
255 UNREACHABLE(); 225 UNREACHABLE();
256 return Handle<Code>::null(); 226 return Handle<Code>::null();
257 } 227 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 277
308 Address address() const { return address_; } 278 Address address() const { return address_; }
309 279
310 IC::UtilityId id() const { return id_; } 280 IC::UtilityId id() const { return id_; }
311 private: 281 private:
312 Address address_; 282 Address address_;
313 IC::UtilityId id_; 283 IC::UtilityId id_;
314 }; 284 };
315 285
316 286
317 enum StringStubFeedback {
318 DEFAULT_STRING_STUB = 0,
319 STRING_INDEX_OUT_OF_BOUNDS = 1
320 };
321
322
323 class CallICBase: public IC { 287 class CallICBase: public IC {
324 public: 288 public:
325 // ExtraICState bits
326 class StringStubState: public BitField<StringStubFeedback, 0, 1> {};
327 static ExtraICState ComputeExtraICState(StringStubFeedback feedback) {
328 return StringStubState::encode(feedback);
329 }
330
331 // Returns a JSFunction or a Failure. 289 // Returns a JSFunction or a Failure.
332 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, 290 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object,
333 Handle<String> name); 291 Handle<String> name);
334 292
335 protected: 293 protected:
336 CallICBase(Code::Kind kind, Isolate* isolate) 294 CallICBase(Code::Kind kind, Isolate* isolate)
337 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} 295 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {}
338 296
339 // Compute a monomorphic stub if possible, otherwise return a null handle. 297 // Compute a monomorphic stub if possible, otherwise return a null handle.
340 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup, 298 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 390 }
433 391
434 static void GenerateMegamorphic(MacroAssembler* masm, int argc); 392 static void GenerateMegamorphic(MacroAssembler* masm, int argc);
435 static void GenerateNormal(MacroAssembler* masm, int argc); 393 static void GenerateNormal(MacroAssembler* masm, int argc);
436 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); 394 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc);
437 }; 395 };
438 396
439 397
440 class LoadIC: public IC { 398 class LoadIC: public IC {
441 public: 399 public:
400 // ExtraICState bits
401 class Contextual: public BitField<ContextualMode, 0, 1> {};
402 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
403
404 static ExtraICState ComputeExtraICState(ContextualMode mode) {
405 return Contextual::encode(mode);
406 }
407
408 static ContextualMode GetContextualMode(ExtraICState state) {
409 return Contextual::decode(state);
410 }
411
412 ContextualMode contextual_mode() const {
413 return Contextual::decode(extra_ic_state());
414 }
415
442 explicit LoadIC(FrameDepth depth, Isolate* isolate) 416 explicit LoadIC(FrameDepth depth, Isolate* isolate)
443 : IC(depth, isolate) { 417 : IC(depth, isolate) {
444 ASSERT(IsLoadStub()); 418 ASSERT(IsLoadStub());
445 } 419 }
446 420
421 // Returns if this IC is for contextual (no explicit receiver)
422 // access to properties.
423 bool IsUndeclaredGlobal(Handle<Object> receiver) {
424 if (receiver->IsGlobalObject()) {
425 return contextual_mode() == CONTEXTUAL;
426 } else {
427 ASSERT(contextual_mode() != CONTEXTUAL);
428 return false;
429 }
430 }
431
447 // Code generator routines. 432 // Code generator routines.
448 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 433 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
449 static void GeneratePreMonomorphic(MacroAssembler* masm) { 434 static void GeneratePreMonomorphic(MacroAssembler* masm) {
450 GenerateMiss(masm); 435 GenerateMiss(masm);
451 } 436 }
452 static void GenerateMiss(MacroAssembler* masm); 437 static void GenerateMiss(MacroAssembler* masm);
453 static void GenerateMegamorphic(MacroAssembler* masm, ContextualMode mode); 438 static void GenerateMegamorphic(MacroAssembler* masm, ContextualMode mode);
454 static void GenerateNormal(MacroAssembler* masm); 439 static void GenerateNormal(MacroAssembler* masm);
455 static void GenerateRuntimeGetProperty(MacroAssembler* masm); 440 static void GenerateRuntimeGetProperty(MacroAssembler* masm);
456 441
457 static Handle<Code> initialize_stub(Isolate* isolate, ContextualMode mode); 442 static Handle<Code> initialize_stub(Isolate* isolate, ContextualMode mode);
458 443
459 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, 444 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object,
460 Handle<String> name); 445 Handle<String> name);
461 446
462 protected: 447 protected:
463 virtual Code::Kind kind() const { return Code::LOAD_IC; } 448 virtual Code::Kind kind() const { return Code::LOAD_IC; }
464 449
450 void set_target(Code* code) {
451 // The contextual mode must be preserved across IC patching.
452 ASSERT(GetContextualMode(code->extra_ic_state()) ==
453 GetContextualMode(target()->extra_ic_state()));
454
455 IC::set_target(code);
456 }
457
465 virtual Handle<Code> slow_stub() const { 458 virtual Handle<Code> slow_stub() const {
466 return isolate()->builtins()->LoadIC_Slow(); 459 return isolate()->builtins()->LoadIC_Slow();
467 } 460 }
468 461
469 virtual Handle<Code> megamorphic_stub(); 462 virtual Handle<Code> megamorphic_stub();
470 463
471 // Update the inline cache and the global stub cache based on the 464 // Update the inline cache and the global stub cache based on the
472 // lookup result. 465 // lookup result.
473 void UpdateCaches(LookupResult* lookup, 466 void UpdateCaches(LookupResult* lookup,
474 Handle<Object> object, 467 Handle<Object> object,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 virtual Handle<Code> megamorphic_stub() { 530 virtual Handle<Code> megamorphic_stub() {
538 return isolate()->builtins()->KeyedLoadIC_Generic(); 531 return isolate()->builtins()->KeyedLoadIC_Generic();
539 } 532 }
540 virtual Handle<Code> generic_stub() const { 533 virtual Handle<Code> generic_stub() const {
541 return isolate()->builtins()->KeyedLoadIC_Generic(); 534 return isolate()->builtins()->KeyedLoadIC_Generic();
542 } 535 }
543 virtual Handle<Code> slow_stub() const { 536 virtual Handle<Code> slow_stub() const {
544 return isolate()->builtins()->KeyedLoadIC_Slow(); 537 return isolate()->builtins()->KeyedLoadIC_Slow();
545 } 538 }
546 539
547 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } 540 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {}
548 541
549 private: 542 private:
550 // Stub accessors. 543 // Stub accessors.
551 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { 544 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) {
552 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); 545 return isolate->builtins()->KeyedLoadIC_PreMonomorphic();
553 } 546 }
554 virtual Handle<Code> pre_monomorphic_stub() { 547 virtual Handle<Code> pre_monomorphic_stub() {
555 return pre_monomorphic_stub(isolate()); 548 return pre_monomorphic_stub(isolate());
556 } 549 }
557 Handle<Code> indexed_interceptor_stub() { 550 Handle<Code> indexed_interceptor_stub() {
558 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); 551 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor();
559 } 552 }
560 Handle<Code> non_strict_arguments_stub() { 553 Handle<Code> non_strict_arguments_stub() {
561 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); 554 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments();
562 } 555 }
563 Handle<Code> string_stub() { 556 Handle<Code> string_stub() {
564 return isolate()->builtins()->KeyedLoadIC_String(); 557 return isolate()->builtins()->KeyedLoadIC_String();
565 } 558 }
566 559
567 static void Clear(Isolate* isolate, Address address, Code* target); 560 static void Clear(Isolate* isolate, Address address, Code* target);
568 561
569 friend class IC; 562 friend class IC;
570 }; 563 };
571 564
572 565
573 class StoreIC: public IC { 566 class StoreIC: public IC {
574 public: 567 public:
575 // ExtraICState bits
576 class StrictModeState: public BitField<StrictModeFlag, 1, 1> {}; 568 class StrictModeState: public BitField<StrictModeFlag, 1, 1> {};
577 static ExtraICState ComputeExtraICState(StrictModeFlag flag) { 569 static ExtraICState ComputeExtraICState(StrictModeFlag flag) {
578 return StrictModeState::encode(flag); 570 return StrictModeState::encode(flag);
579 } 571 }
580 572
581 static ExtraICState ComputeExtraICState(StrictModeFlag flag,
582 ContextualMode mode) {
583 return StrictModeState::encode(flag) | Contextual::encode(mode);
584 }
585
586 static StrictModeFlag GetStrictMode(ExtraICState state) { 573 static StrictModeFlag GetStrictMode(ExtraICState state) {
587 return StrictModeState::decode(state); 574 return StrictModeState::decode(state);
588 } 575 }
589 576
590 // For convenience, a statically declared encoding of strict mode extra 577 // For convenience, a statically declared encoding of strict mode extra
591 // IC state. 578 // IC state.
592 static const ExtraICState kStrictModeState = 579 static const ExtraICState kStrictModeState =
593 1 << StrictModeState::kShift; 580 1 << StrictModeState::kShift;
594 581
595 StoreIC(FrameDepth depth, Isolate* isolate) 582 StoreIC(FrameDepth depth, Isolate* isolate)
(...skipping 12 matching lines...) Expand all
608 GenerateMiss(masm); 595 GenerateMiss(masm);
609 } 596 }
610 static void GenerateMiss(MacroAssembler* masm); 597 static void GenerateMiss(MacroAssembler* masm);
611 static void GenerateMegamorphic(MacroAssembler* masm, 598 static void GenerateMegamorphic(MacroAssembler* masm,
612 ExtraICState extra_ic_state); 599 ExtraICState extra_ic_state);
613 static void GenerateNormal(MacroAssembler* masm); 600 static void GenerateNormal(MacroAssembler* masm);
614 static void GenerateRuntimeSetProperty(MacroAssembler* masm, 601 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
615 StrictModeFlag strict_mode); 602 StrictModeFlag strict_mode);
616 603
617 static Handle<Code> initialize_stub(Isolate* isolate, 604 static Handle<Code> initialize_stub(Isolate* isolate,
618 StrictModeFlag strict_mode, 605 StrictModeFlag strict_mode);
619 ContextualMode mode);
620 606
621 MUST_USE_RESULT MaybeObject* Store( 607 MUST_USE_RESULT MaybeObject* Store(
622 Handle<Object> object, 608 Handle<Object> object,
623 Handle<String> name, 609 Handle<String> name,
624 Handle<Object> value, 610 Handle<Object> value,
625 JSReceiver::StoreFromKeyed store_mode = 611 JSReceiver::StoreFromKeyed store_mode =
626 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); 612 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED);
627 613
628 protected: 614 protected:
629 virtual Code::Kind kind() const { return Code::STORE_IC; } 615 virtual Code::Kind kind() const { return Code::STORE_IC; }
630 virtual Handle<Code> megamorphic_stub(); 616 virtual Handle<Code> megamorphic_stub();
631 617
632 // Stub accessors. 618 // Stub accessors.
633 virtual Handle<Code> generic_stub() const; 619 virtual Handle<Code> generic_stub() const;
634 620
635 virtual Handle<Code> slow_stub() const { 621 virtual Handle<Code> slow_stub() const {
636 return isolate()->builtins()->StoreIC_Slow(); 622 return isolate()->builtins()->StoreIC_Slow();
637 } 623 }
638 624
639 virtual Handle<Code> pre_monomorphic_stub() { 625 virtual Handle<Code> pre_monomorphic_stub() {
640 return pre_monomorphic_stub(isolate(), strict_mode(), contextual_mode()); 626 return pre_monomorphic_stub(isolate(), strict_mode());
641 } 627 }
642 628
643 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, 629 static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
644 StrictModeFlag strict_mode, 630 StrictModeFlag strict_mode);
645 ContextualMode contextual_mode);
646 631
647 // Update the inline cache and the global stub cache based on the 632 // Update the inline cache and the global stub cache based on the
648 // lookup result. 633 // lookup result.
649 void UpdateCaches(LookupResult* lookup, 634 void UpdateCaches(LookupResult* lookup,
650 Handle<JSObject> receiver, 635 Handle<JSObject> receiver,
651 Handle<String> name, 636 Handle<String> name,
652 Handle<Object> value); 637 Handle<Object> value);
653 virtual Handle<Code> CompileHandler(LookupResult* lookup, 638 virtual Handle<Code> CompileHandler(LookupResult* lookup,
654 Handle<Object> object, 639 Handle<Object> object,
655 Handle<String> name, 640 Handle<String> name,
656 Handle<Object> value, 641 Handle<Object> value,
657 InlineCacheHolderFlag cache_holder); 642 InlineCacheHolderFlag cache_holder);
658 643
659 private: 644 private:
660 void set_target(Code* code) { 645 void set_target(Code* code) {
661 // Strict mode must be preserved across IC patching. 646 // Strict mode must be preserved across IC patching.
662 ASSERT(GetStrictMode(code->extra_ic_state()) == 647 ASSERT(GetStrictMode(code->extra_ic_state()) ==
663 GetStrictMode(target()->extra_ic_state())); 648 GetStrictMode(target()->extra_ic_state()));
664 // As must the contextual mode
665 ASSERT(GetContextualMode(code->extra_ic_state()) ==
666 GetContextualMode(target()->extra_ic_state()));
667 IC::set_target(code); 649 IC::set_target(code);
668 } 650 }
669 651
670 static void Clear(Isolate* isolate, Address address, Code* target); 652 static void Clear(Isolate* isolate, Address address, Code* target);
671 653
672 friend class IC; 654 friend class IC;
673 }; 655 };
674 656
675 657
676 enum KeyedStoreCheckMap { 658 enum KeyedStoreCheckMap {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 static void GenerateMiss(MacroAssembler* masm); 702 static void GenerateMiss(MacroAssembler* masm);
721 static void GenerateSlow(MacroAssembler* masm); 703 static void GenerateSlow(MacroAssembler* masm);
722 static void GenerateRuntimeSetProperty(MacroAssembler* masm, 704 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
723 StrictModeFlag strict_mode); 705 StrictModeFlag strict_mode);
724 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); 706 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode);
725 static void GenerateNonStrictArguments(MacroAssembler* masm); 707 static void GenerateNonStrictArguments(MacroAssembler* masm);
726 708
727 protected: 709 protected:
728 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } 710 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
729 711
730 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } 712 virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {}
731 713
732 virtual Handle<Code> pre_monomorphic_stub() { 714 virtual Handle<Code> pre_monomorphic_stub() {
733 return pre_monomorphic_stub(isolate(), strict_mode()); 715 return pre_monomorphic_stub(isolate(), strict_mode());
734 } 716 }
735 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, 717 static Handle<Code> pre_monomorphic_stub(Isolate* isolate,
736 StrictModeFlag strict_mode) { 718 StrictModeFlag strict_mode) {
737 if (strict_mode == kStrictMode) { 719 if (strict_mode == kStrictMode) {
738 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); 720 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict();
739 } else { 721 } else {
740 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); 722 return isolate->builtins()->KeyedStoreIC_PreMonomorphic();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 return KindMaybeSmi(left_kind_) || KindMaybeSmi(right_kind_); 837 return KindMaybeSmi(left_kind_) || KindMaybeSmi(right_kind_);
856 } 838 }
857 839
858 static const int FIRST_TOKEN = Token::BIT_OR; 840 static const int FIRST_TOKEN = Token::BIT_OR;
859 static const int LAST_TOKEN = Token::MOD; 841 static const int LAST_TOKEN = Token::MOD;
860 842
861 Token::Value op() const { return op_; } 843 Token::Value op() const { return op_; }
862 OverwriteMode mode() const { return mode_; } 844 OverwriteMode mode() const { return mode_; }
863 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } 845 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
864 846
865 Handle<Type> GetLeftType(Isolate* isolate) const { 847 Type* GetLeftType(Zone* zone) const {
866 return KindToType(left_kind_, isolate); 848 return KindToType(left_kind_, zone);
867 } 849 }
868 Handle<Type> GetRightType(Isolate* isolate) const { 850 Type* GetRightType(Zone* zone) const {
869 return KindToType(right_kind_, isolate); 851 return KindToType(right_kind_, zone);
870 } 852 }
871 Handle<Type> GetResultType(Isolate* isolate) const; 853 Type* GetResultType(Zone* zone) const;
872 854
873 void Print(StringStream* stream) const; 855 void Print(StringStream* stream) const;
874 856
875 void Update(Handle<Object> left, 857 void Update(Handle<Object> left,
876 Handle<Object> right, 858 Handle<Object> right,
877 Handle<Object> result); 859 Handle<Object> result);
878 860
879 private: 861 private:
880 enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC }; 862 enum Kind { NONE, SMI, INT32, NUMBER, STRING, GENERIC };
881 863
882 Kind UpdateKind(Handle<Object> object, Kind kind) const; 864 Kind UpdateKind(Handle<Object> object, Kind kind) const;
883 865
884 static const char* KindToString(Kind kind); 866 static const char* KindToString(Kind kind);
885 static Handle<Type> KindToType(Kind kind, Isolate* isolate); 867 static Type* KindToType(Kind kind, Zone* zone);
886 static bool KindMaybeSmi(Kind kind) { 868 static bool KindMaybeSmi(Kind kind) {
887 return (kind >= SMI && kind <= NUMBER) || kind == GENERIC; 869 return (kind >= SMI && kind <= NUMBER) || kind == GENERIC;
888 } 870 }
889 871
890 // We truncate the last bit of the token. 872 // We truncate the last bit of the token.
891 STATIC_ASSERT(LAST_TOKEN - FIRST_TOKEN < (1 << 4)); 873 STATIC_ASSERT(LAST_TOKEN - FIRST_TOKEN < (1 << 4));
892 class OpField: public BitField<int, 0, 4> {}; 874 class OpField: public BitField<int, 0, 4> {};
893 class OverwriteModeField: public BitField<OverwriteMode, 4, 2> {}; 875 class OverwriteModeField: public BitField<OverwriteMode, 4, 2> {};
894 class SSE2Field: public BitField<bool, 6, 1> {}; 876 class SSE2Field: public BitField<bool, 6, 1> {};
895 class ResultKindField: public BitField<Kind, 7, 3> {}; 877 class ResultKindField: public BitField<Kind, 7, 3> {};
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 STRING, 915 STRING,
934 INTERNALIZED_STRING, 916 INTERNALIZED_STRING,
935 UNIQUE_NAME, // Symbol or InternalizedString 917 UNIQUE_NAME, // Symbol or InternalizedString
936 OBJECT, // JSObject 918 OBJECT, // JSObject
937 KNOWN_OBJECT, // JSObject with specific map (faster check) 919 KNOWN_OBJECT, // JSObject with specific map (faster check)
938 GENERIC 920 GENERIC
939 }; 921 };
940 922
941 static State NewInputState(State old_state, Handle<Object> value); 923 static State NewInputState(State old_state, Handle<Object> value);
942 924
943 static Handle<Type> StateToType(Isolate* isolate, 925 static Type* StateToType(Zone* zone,
944 State state, 926 State state,
945 Handle<Map> map = Handle<Map>()); 927 Handle<Map> map = Handle<Map>());
946 928
947 static void StubInfoToType(int stub_minor_key, 929 static void StubInfoToType(int stub_minor_key,
948 Handle<Type>* left_type, 930 Type** left_type,
949 Handle<Type>* right_type, 931 Type** right_type,
950 Handle<Type>* overall_type, 932 Type** overall_type,
951 Handle<Map> map, 933 Handle<Map> map,
952 Isolate* isolate); 934 Zone* zone);
953 935
954 CompareIC(Isolate* isolate, Token::Value op) 936 CompareIC(Isolate* isolate, Token::Value op)
955 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { } 937 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { }
956 938
957 // Update the inline cache for the given operands. 939 // Update the inline cache for the given operands.
958 Code* UpdateCaches(Handle<Object> x, Handle<Object> y); 940 Code* UpdateCaches(Handle<Object> x, Handle<Object> y);
959 941
960 942
961 // Factory method for getting an uninitialized compare stub. 943 // Factory method for getting an uninitialized compare stub.
962 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op); 944 static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); 1006 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss);
1025 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); 1007 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss);
1026 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); 1008 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite);
1027 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); 1009 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
1028 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); 1010 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss);
1029 1011
1030 1012
1031 } } // namespace v8::internal 1013 } } // namespace v8::internal
1032 1014
1033 #endif // V8_IC_H_ 1015 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698