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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 // Alias the inline cache state type to make the IC code more readable. | 80 // Alias the inline cache state type to make the IC code more readable. |
81 typedef InlineCacheState State; | 81 typedef InlineCacheState State; |
82 | 82 |
83 // The IC code is either invoked with no extra frames on the stack | 83 // The IC code is either invoked with no extra frames on the stack |
84 // or with a single extra frame for supporting calls. | 84 // or with a single extra frame for supporting calls. |
85 enum FrameDepth { | 85 enum FrameDepth { |
86 NO_EXTRA_FRAME = 0, | 86 NO_EXTRA_FRAME = 0, |
87 EXTRA_CALL_FRAME = 1 | 87 EXTRA_CALL_FRAME = 1 |
88 }; | 88 }; |
89 | 89 |
90 // ExtraICState shared by all ICs. | |
91 class Contextual: public BitField<ContextualMode, 0, 1> {}; | |
92 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); | |
93 static ExtraICState ComputeExtraICState(ContextualMode mode) { | |
94 return Contextual::encode(mode); | |
95 } | |
96 | |
97 static ContextualMode GetContextualMode(ExtraICState state) { | |
98 return Contextual::decode(state); | |
99 } | |
100 | |
101 static const ExtraICState kContextualState = | |
102 static_cast<int>(CONTEXTUAL) << Contextual::kShift; | |
103 | |
90 // Construct the IC structure with the given number of extra | 104 // Construct the IC structure with the given number of extra |
91 // JavaScript frames on the stack. | 105 // JavaScript frames on the stack. |
92 IC(FrameDepth depth, Isolate* isolate); | 106 IC(FrameDepth depth, Isolate* isolate); |
93 virtual ~IC() {} | 107 virtual ~IC() {} |
94 | 108 |
95 State state() const { return state_; } | 109 State state() const { return state_; } |
96 inline Address address() const; | 110 inline Address address() const; |
97 | 111 |
98 // Compute the current IC state based on the target stub, receiver and name. | 112 // Compute the current IC state based on the target stub, receiver and name. |
99 void UpdateState(Handle<Object> receiver, Handle<Object> name); | 113 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
100 void MarkMonomorphicPrototypeFailure() { | 114 void MarkMonomorphicPrototypeFailure() { |
101 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; | 115 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; |
102 } | 116 } |
103 | 117 |
104 // Clear the inline cache to initial state. | 118 // Clear the inline cache to initial state. |
105 static void Clear(Isolate* isolate, Address address); | 119 static void Clear(Isolate* isolate, Address address); |
106 | 120 |
107 // Computes the reloc info for this IC. This is a fairly expensive | |
108 // operation as it has to search through the heap to find the code | |
109 // object that contains this IC site. | |
110 RelocInfo::Mode ComputeMode(); | |
111 | |
112 // Returns if this IC is for contextual (no explicit receiver) | 121 // Returns if this IC is for contextual (no explicit receiver) |
113 // access to properties. | 122 // access to properties. |
114 bool IsUndeclaredGlobal(Handle<Object> receiver) { | 123 bool IsUndeclaredGlobal(Handle<Object> receiver) { |
115 if (receiver->IsGlobalObject()) { | 124 if (receiver->IsGlobalObject()) { |
116 return SlowIsUndeclaredGlobal(); | 125 return contextual_mode(); |
Toon Verwaest
2013/12/04 18:10:52
Casting ContextualMode to bool? Please either retu
mvstanton
2013/12/04 22:08:10
Yikes, that was unintentional, thx for catching. F
| |
117 } else { | 126 } else { |
118 ASSERT(!SlowIsUndeclaredGlobal()); | 127 ASSERT(!contextual_mode()); |
119 return false; | 128 return false; |
120 } | 129 } |
121 } | 130 } |
122 | 131 |
123 bool SlowIsUndeclaredGlobal() { | |
124 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; | |
125 } | |
126 | |
127 #ifdef DEBUG | 132 #ifdef DEBUG |
128 bool IsLoadStub() { | 133 bool IsLoadStub() { |
129 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 134 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
130 } | 135 } |
131 | 136 |
132 bool IsStoreStub() { | 137 bool IsStoreStub() { |
133 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 138 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
134 } | 139 } |
135 | 140 |
136 bool IsCallStub() { | 141 bool IsCallStub() { |
(...skipping 23 matching lines...) Expand all Loading... | |
160 | 165 |
161 // Utility functions to convert maps to types and back. There are two special | 166 // Utility functions to convert maps to types and back. There are two special |
162 // cases: | 167 // cases: |
163 // - The heap_number_map is used as a marker which includes heap numbers as | 168 // - The heap_number_map is used as a marker which includes heap numbers as |
164 // well as smis. | 169 // well as smis. |
165 // - The oddball map is only used for booleans. | 170 // - The oddball map is only used for booleans. |
166 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); | 171 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); |
167 static Type* MapToType(Handle<Map> type); | 172 static Type* MapToType(Handle<Map> type); |
168 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); | 173 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); |
169 | 174 |
175 ContextualMode contextual_mode() const { | |
176 return Contextual::decode(extra_ic_state()); | |
177 } | |
178 | |
170 protected: | 179 protected: |
171 // Get the call-site target; used for determining the state. | 180 // Get the call-site target; used for determining the state. |
172 Handle<Code> target() const { return target_; } | 181 Handle<Code> target() const { return target_; } |
173 | 182 |
174 Address fp() const { return fp_; } | 183 Address fp() const { return fp_; } |
175 Address pc() const { return *pc_address_; } | 184 Address pc() const { return *pc_address_; } |
176 Isolate* isolate() const { return isolate_; } | 185 Isolate* isolate() const { return isolate_; } |
177 | 186 |
178 #ifdef ENABLE_DEBUGGER_SUPPORT | 187 #ifdef ENABLE_DEBUGGER_SUPPORT |
179 // Computes the address in the original code when the code running is | 188 // Computes the address in the original code when the code running is |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 } | 257 } |
249 virtual Handle<Code> generic_stub() const { | 258 virtual Handle<Code> generic_stub() const { |
250 UNREACHABLE(); | 259 UNREACHABLE(); |
251 return Handle<Code>::null(); | 260 return Handle<Code>::null(); |
252 } | 261 } |
253 | 262 |
254 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 263 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
255 Handle<String> name); | 264 Handle<String> name); |
256 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); | 265 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); |
257 | 266 |
258 virtual ExtraICState extra_ic_state() { return kNoExtraICState; } | 267 ExtraICState extra_ic_state() const { return extra_ic_state_; } |
268 void set_extra_ic_state(ExtraICState state) { | |
269 extra_ic_state_ = state; | |
270 } | |
Toon Verwaest
2013/12/04 18:10:52
Do we really want this setter? Shouldn't that just
mvstanton
2013/12/04 22:08:10
I'll argue one more time to keep the setter, it al
| |
259 | 271 |
260 private: | 272 private: |
261 Code* raw_target() const { return GetTargetAtAddress(address()); } | 273 Code* raw_target() const { return GetTargetAtAddress(address()); } |
262 | 274 |
263 // Frame pointer for the frame that uses (calls) the IC. | 275 // Frame pointer for the frame that uses (calls) the IC. |
264 Address fp_; | 276 Address fp_; |
265 | 277 |
266 // All access to the program counter of an IC structure is indirect | 278 // All access to the program counter of an IC structure is indirect |
267 // to make the code GC safe. This feature is crucial since | 279 // to make the code GC safe. This feature is crucial since |
268 // GetProperty and SetProperty are called and they in turn might | 280 // GetProperty and SetProperty are called and they in turn might |
269 // invoke the garbage collector. | 281 // invoke the garbage collector. |
270 Address* pc_address_; | 282 Address* pc_address_; |
271 | 283 |
272 Isolate* isolate_; | 284 Isolate* isolate_; |
273 | 285 |
274 // The original code target that missed. | 286 // The original code target that missed. |
275 Handle<Code> target_; | 287 Handle<Code> target_; |
276 State state_; | 288 State state_; |
277 bool target_set_; | 289 bool target_set_; |
278 | 290 |
291 ExtraICState extra_ic_state_; | |
292 | |
279 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 293 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
280 }; | 294 }; |
281 | 295 |
282 | 296 |
283 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you | 297 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you |
284 // cannot make forward declarations to an enum. | 298 // cannot make forward declarations to an enum. |
285 class IC_Utility { | 299 class IC_Utility { |
286 public: | 300 public: |
287 explicit IC_Utility(IC::UtilityId id) | 301 explicit IC_Utility(IC::UtilityId id) |
288 : address_(IC::AddressFromUtilityId(id)), id_(id) {} | 302 : address_(IC::AddressFromUtilityId(id)), id_(id) {} |
289 | 303 |
290 Address address() const { return address_; } | 304 Address address() const { return address_; } |
291 | 305 |
292 IC::UtilityId id() const { return id_; } | 306 IC::UtilityId id() const { return id_; } |
293 private: | 307 private: |
294 Address address_; | 308 Address address_; |
295 IC::UtilityId id_; | 309 IC::UtilityId id_; |
296 }; | 310 }; |
297 | 311 |
298 | 312 |
299 class CallICBase: public IC { | 313 class CallICBase: public IC { |
300 public: | 314 public: |
301 // ExtraICState bits | 315 // ExtraICState bits |
302 class Contextual: public BitField<ContextualMode, 0, 1> {}; | |
303 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; | 316 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; |
304 static ExtraICState ComputeExtraICState(ContextualMode mode, | 317 static ExtraICState ComputeExtraICState(ContextualMode mode, |
305 StringStubFeedback feedback) { | 318 StringStubFeedback feedback) { |
306 return Contextual::encode(mode) | StringStubState::encode(feedback); | 319 return Contextual::encode(mode) | StringStubState::encode(feedback); |
307 } | 320 } |
308 | 321 |
309 // Returns a JSFunction or a Failure. | 322 // Returns a JSFunction or a Failure. |
310 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, | 323 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, |
311 Handle<String> name); | 324 Handle<String> name); |
312 | 325 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 | 366 |
354 Code::Kind kind_; | 367 Code::Kind kind_; |
355 | 368 |
356 friend class IC; | 369 friend class IC; |
357 }; | 370 }; |
358 | 371 |
359 | 372 |
360 class CallIC: public CallICBase { | 373 class CallIC: public CallICBase { |
361 public: | 374 public: |
362 explicit CallIC(Isolate* isolate) | 375 explicit CallIC(Isolate* isolate) |
363 : CallICBase(Code::CALL_IC, isolate), | 376 : CallICBase(Code::CALL_IC, isolate) { |
364 extra_ic_state_(target()->extra_ic_state()) { | |
365 ASSERT(target()->is_call_stub()); | 377 ASSERT(target()->is_call_stub()); |
366 } | 378 } |
367 | 379 |
368 // Code generator routines. | 380 // Code generator routines. |
369 static void GenerateInitialize(MacroAssembler* masm, | 381 static void GenerateInitialize(MacroAssembler* masm, |
370 int argc, | 382 int argc, |
371 ExtraICState extra_state) { | 383 ExtraICState extra_state) { |
372 GenerateMiss(masm, argc, extra_state); | 384 GenerateMiss(masm, argc, extra_state); |
373 } | 385 } |
374 | 386 |
375 static void GenerateMiss(MacroAssembler* masm, | 387 static void GenerateMiss(MacroAssembler* masm, |
376 int argc, | 388 int argc, |
377 ExtraICState extra_state) { | 389 ExtraICState extra_state) { |
378 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); | 390 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); |
379 } | 391 } |
380 | 392 |
381 static void GenerateMegamorphic(MacroAssembler* masm, | 393 static void GenerateMegamorphic(MacroAssembler* masm, |
382 int argc, | 394 int argc, |
383 ExtraICState extra_ic_state); | 395 ExtraICState extra_ic_state); |
384 | 396 |
385 static void GenerateNormal(MacroAssembler* masm, int argc) { | 397 static void GenerateNormal(MacroAssembler* masm, int argc) { |
386 CallICBase::GenerateNormal(masm, argc); | 398 CallICBase::GenerateNormal(masm, argc); |
387 GenerateMiss(masm, argc, kNoExtraICState); | 399 GenerateMiss(masm, argc, kNoExtraICState); |
388 } | 400 } |
389 bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object); | 401 bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object); |
390 | |
391 protected: | |
392 virtual ExtraICState extra_ic_state() { return extra_ic_state_; } | |
393 | |
394 private: | |
395 ExtraICState extra_ic_state_; | |
396 }; | 402 }; |
397 | 403 |
398 | 404 |
399 class KeyedCallIC: public CallICBase { | 405 class KeyedCallIC: public CallICBase { |
400 public: | 406 public: |
401 explicit KeyedCallIC(Isolate* isolate) | 407 explicit KeyedCallIC(Isolate* isolate) |
402 : CallICBase(Code::KEYED_CALL_IC, isolate) { | 408 : CallICBase(Code::KEYED_CALL_IC, isolate) { |
403 ASSERT(target()->is_keyed_call_stub()); | 409 ASSERT(target()->is_keyed_call_stub()); |
404 } | 410 } |
405 | 411 |
(...skipping 11 matching lines...) Expand all Loading... | |
417 } | 423 } |
418 | 424 |
419 static void GenerateMegamorphic(MacroAssembler* masm, int argc); | 425 static void GenerateMegamorphic(MacroAssembler* masm, int argc); |
420 static void GenerateNormal(MacroAssembler* masm, int argc); | 426 static void GenerateNormal(MacroAssembler* masm, int argc); |
421 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); | 427 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); |
422 }; | 428 }; |
423 | 429 |
424 | 430 |
425 class LoadIC: public IC { | 431 class LoadIC: public IC { |
426 public: | 432 public: |
427 explicit LoadIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) { | 433 explicit LoadIC(FrameDepth depth, Isolate* isolate) |
434 : IC(depth, isolate) { | |
428 ASSERT(IsLoadStub()); | 435 ASSERT(IsLoadStub()); |
429 } | 436 } |
430 | 437 |
431 // Code generator routines. | 438 // Code generator routines. |
432 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 439 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
433 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 440 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
434 GenerateMiss(masm); | 441 GenerateMiss(masm); |
435 } | 442 } |
436 static void GenerateMiss(MacroAssembler* masm); | 443 static void GenerateMiss(MacroAssembler* masm); |
437 static void GenerateMegamorphic(MacroAssembler* masm); | 444 static void GenerateMegamorphic(MacroAssembler* masm, ContextualMode mode); |
438 static void GenerateNormal(MacroAssembler* masm); | 445 static void GenerateNormal(MacroAssembler* masm); |
439 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 446 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
440 | 447 |
448 static Handle<Code> initialize_stub(Isolate* isolate, ContextualMode mode); | |
449 | |
441 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, | 450 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, |
442 Handle<String> name); | 451 Handle<String> name); |
443 | 452 |
444 protected: | 453 protected: |
445 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 454 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
446 | 455 |
447 virtual Handle<Code> slow_stub() const { | 456 virtual Handle<Code> slow_stub() const { |
448 return isolate()->builtins()->LoadIC_Slow(); | 457 return isolate()->builtins()->LoadIC_Slow(); |
449 } | 458 } |
450 | 459 |
451 virtual Handle<Code> megamorphic_stub() { | 460 virtual Handle<Code> megamorphic_stub(); |
452 return isolate()->builtins()->LoadIC_Megamorphic(); | |
453 } | |
454 | 461 |
455 // Update the inline cache and the global stub cache based on the | 462 // Update the inline cache and the global stub cache based on the |
456 // lookup result. | 463 // lookup result. |
457 void UpdateCaches(LookupResult* lookup, | 464 void UpdateCaches(LookupResult* lookup, |
458 Handle<Object> object, | 465 Handle<Object> object, |
459 Handle<String> name); | 466 Handle<String> name); |
460 | 467 |
461 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 468 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
462 Handle<Object> object, | 469 Handle<Object> object, |
463 Handle<String> name, | 470 Handle<String> name, |
464 Handle<Object> unused, | 471 Handle<Object> unused, |
465 InlineCacheHolderFlag cache_holder); | 472 InlineCacheHolderFlag cache_holder); |
466 | 473 |
467 private: | 474 private: |
468 // Stub accessors. | 475 // Stub accessors. |
469 static Handle<Code> initialize_stub(Isolate* isolate) { | 476 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
470 return isolate->builtins()->LoadIC_Initialize(); | 477 ContextualMode mode); |
471 } | |
472 | |
473 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | |
474 return isolate->builtins()->LoadIC_PreMonomorphic(); | |
475 } | |
476 | 478 |
477 virtual Handle<Code> pre_monomorphic_stub() { | 479 virtual Handle<Code> pre_monomorphic_stub() { |
478 return pre_monomorphic_stub(isolate()); | 480 return pre_monomorphic_stub(isolate(), contextual_mode()); |
479 } | 481 } |
480 | 482 |
481 Handle<Code> SimpleFieldLoad(int offset, | 483 Handle<Code> SimpleFieldLoad(int offset, |
482 bool inobject = true, | 484 bool inobject = true, |
483 Representation representation = | 485 Representation representation = |
484 Representation::Tagged()); | 486 Representation::Tagged()); |
485 | 487 |
486 static void Clear(Isolate* isolate, Address address, Code* target); | 488 static void Clear(Isolate* isolate, Address address, Code* target); |
487 | 489 |
488 friend class IC; | 490 friend class IC; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 return isolate()->builtins()->KeyedLoadIC_Generic(); | 532 return isolate()->builtins()->KeyedLoadIC_Generic(); |
531 } | 533 } |
532 virtual Handle<Code> slow_stub() const { | 534 virtual Handle<Code> slow_stub() const { |
533 return isolate()->builtins()->KeyedLoadIC_Slow(); | 535 return isolate()->builtins()->KeyedLoadIC_Slow(); |
534 } | 536 } |
535 | 537 |
536 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 538 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
537 | 539 |
538 private: | 540 private: |
539 // Stub accessors. | 541 // Stub accessors. |
540 static Handle<Code> initialize_stub(Isolate* isolate) { | |
541 return isolate->builtins()->KeyedLoadIC_Initialize(); | |
542 } | |
543 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 542 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { |
544 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | 543 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); |
545 } | 544 } |
546 virtual Handle<Code> pre_monomorphic_stub() { | 545 virtual Handle<Code> pre_monomorphic_stub() { |
547 return pre_monomorphic_stub(isolate()); | 546 return pre_monomorphic_stub(isolate()); |
548 } | 547 } |
549 Handle<Code> indexed_interceptor_stub() { | 548 Handle<Code> indexed_interceptor_stub() { |
550 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 549 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
551 } | 550 } |
552 Handle<Code> non_strict_arguments_stub() { | 551 Handle<Code> non_strict_arguments_stub() { |
553 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); | 552 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); |
554 } | 553 } |
555 Handle<Code> string_stub() { | 554 Handle<Code> string_stub() { |
556 return isolate()->builtins()->KeyedLoadIC_String(); | 555 return isolate()->builtins()->KeyedLoadIC_String(); |
557 } | 556 } |
558 | 557 |
559 static void Clear(Isolate* isolate, Address address, Code* target); | 558 static void Clear(Isolate* isolate, Address address, Code* target); |
560 | 559 |
561 friend class IC; | 560 friend class IC; |
562 }; | 561 }; |
563 | 562 |
564 | 563 |
565 class StoreIC: public IC { | 564 class StoreIC: public IC { |
566 public: | 565 public: |
567 // ExtraICState bits | 566 // ExtraICState bits |
568 class StrictModeState: public BitField<StrictModeFlag, 0, 1> {}; | 567 class StrictModeState: public BitField<StrictModeFlag, 1, 1> {}; |
569 static ExtraICState ComputeExtraICState(StrictModeFlag flag) { | 568 static ExtraICState ComputeExtraICState(StrictModeFlag flag) { |
570 return StrictModeState::encode(flag); | 569 return StrictModeState::encode(flag); |
571 } | 570 } |
572 | 571 |
572 static ExtraICState ComputeExtraICState(StrictModeFlag flag, | |
573 ContextualMode mode) { | |
574 return StrictModeState::encode(flag) | Contextual::encode(mode); | |
575 } | |
576 | |
573 static StrictModeFlag GetStrictMode(ExtraICState state) { | 577 static StrictModeFlag GetStrictMode(ExtraICState state) { |
574 return StrictModeState::decode(state); | 578 return StrictModeState::decode(state); |
575 } | 579 } |
576 | 580 |
577 // For convenience, a statically declared encoding of strict mode extra | 581 // For convenience, a statically declared encoding of strict mode extra |
578 // IC state. | 582 // IC state. |
579 static const ExtraICState kStrictModeState = | 583 static const ExtraICState kStrictModeState = |
580 1 << StrictModeState::kShift; | 584 1 << StrictModeState::kShift; |
581 | 585 |
582 StoreIC(FrameDepth depth, Isolate* isolate) | 586 StoreIC(FrameDepth depth, Isolate* isolate) |
583 : IC(depth, isolate), | 587 : IC(depth, isolate) { |
584 strict_mode_(GetStrictMode(target()->extra_ic_state())) { | |
585 ASSERT(IsStoreStub()); | 588 ASSERT(IsStoreStub()); |
586 } | 589 } |
587 | 590 |
588 StrictModeFlag strict_mode() const { return strict_mode_; } | 591 StrictModeFlag strict_mode() const { |
592 return StrictModeState::decode(extra_ic_state()); | |
593 } | |
589 | 594 |
590 // Code generators for stub routines. Only called once at startup. | 595 // Code generators for stub routines. Only called once at startup. |
591 static void GenerateSlow(MacroAssembler* masm); | 596 static void GenerateSlow(MacroAssembler* masm); |
592 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 597 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
593 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 598 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
594 GenerateMiss(masm); | 599 GenerateMiss(masm); |
595 } | 600 } |
596 static void GenerateMiss(MacroAssembler* masm); | 601 static void GenerateMiss(MacroAssembler* masm); |
597 static void GenerateMegamorphic(MacroAssembler* masm, | 602 static void GenerateMegamorphic(MacroAssembler* masm, |
598 StrictModeFlag strict_mode); | 603 ExtraICState extra_ic_state); |
599 static void GenerateNormal(MacroAssembler* masm); | 604 static void GenerateNormal(MacroAssembler* masm); |
600 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 605 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
601 StrictModeFlag strict_mode); | 606 StrictModeFlag strict_mode); |
602 | 607 |
608 static Handle<Code> initialize_stub(Isolate* isolate, | |
609 StrictModeFlag strict_mode, | |
610 ContextualMode mode); | |
611 | |
603 MUST_USE_RESULT MaybeObject* Store( | 612 MUST_USE_RESULT MaybeObject* Store( |
604 Handle<Object> object, | 613 Handle<Object> object, |
605 Handle<String> name, | 614 Handle<String> name, |
606 Handle<Object> value, | 615 Handle<Object> value, |
607 JSReceiver::StoreFromKeyed store_mode = | 616 JSReceiver::StoreFromKeyed store_mode = |
608 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 617 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
609 | 618 |
610 protected: | 619 protected: |
611 virtual Code::Kind kind() const { return Code::STORE_IC; } | 620 virtual Code::Kind kind() const { return Code::STORE_IC; } |
612 virtual Handle<Code> megamorphic_stub() { | 621 virtual Handle<Code> megamorphic_stub(); |
613 if (strict_mode() == kStrictMode) { | 622 |
614 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); | |
615 } else { | |
616 return isolate()->builtins()->StoreIC_Megamorphic(); | |
617 } | |
618 } | |
619 // Stub accessors. | 623 // Stub accessors. |
620 virtual Handle<Code> generic_stub() const { | 624 virtual Handle<Code> generic_stub() const; |
621 if (strict_mode() == kStrictMode) { | |
622 return isolate()->builtins()->StoreIC_Generic_Strict(); | |
623 } else { | |
624 return isolate()->builtins()->StoreIC_Generic(); | |
625 } | |
626 } | |
627 | 625 |
628 virtual Handle<Code> slow_stub() const { | 626 virtual Handle<Code> slow_stub() const { |
629 return isolate()->builtins()->StoreIC_Slow(); | 627 return isolate()->builtins()->StoreIC_Slow(); |
630 } | 628 } |
631 | 629 |
632 virtual Handle<Code> pre_monomorphic_stub() { | 630 virtual Handle<Code> pre_monomorphic_stub() { |
633 return pre_monomorphic_stub(isolate(), strict_mode()); | 631 return pre_monomorphic_stub(isolate(), strict_mode(), contextual_mode()); |
634 } | 632 } |
635 | 633 |
636 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 634 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
637 StrictModeFlag strict_mode) { | 635 StrictModeFlag strict_mode, |
638 if (strict_mode == kStrictMode) { | 636 ContextualMode contextual_mode); |
639 return isolate->builtins()->StoreIC_PreMonomorphic_Strict(); | |
640 } else { | |
641 return isolate->builtins()->StoreIC_PreMonomorphic(); | |
642 } | |
643 } | |
644 | 637 |
645 // Update the inline cache and the global stub cache based on the | 638 // Update the inline cache and the global stub cache based on the |
646 // lookup result. | 639 // lookup result. |
647 void UpdateCaches(LookupResult* lookup, | 640 void UpdateCaches(LookupResult* lookup, |
648 Handle<JSObject> receiver, | 641 Handle<JSObject> receiver, |
649 Handle<String> name, | 642 Handle<String> name, |
650 Handle<Object> value); | 643 Handle<Object> value); |
651 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 644 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
652 Handle<Object> object, | 645 Handle<Object> object, |
653 Handle<String> name, | 646 Handle<String> name, |
654 Handle<Object> value, | 647 Handle<Object> value, |
655 InlineCacheHolderFlag cache_holder); | 648 InlineCacheHolderFlag cache_holder); |
656 | 649 |
657 virtual ExtraICState extra_ic_state() { | |
658 return ComputeExtraICState(strict_mode()); | |
659 } | |
660 | |
661 private: | 650 private: |
662 void set_target(Code* code) { | 651 void set_target(Code* code) { |
663 // Strict mode must be preserved across IC patching. | 652 // Strict mode must be preserved across IC patching. |
664 ASSERT(GetStrictMode(code->extra_ic_state()) == | 653 ASSERT(GetStrictMode(code->extra_ic_state()) == |
665 GetStrictMode(target()->extra_ic_state())); | 654 GetStrictMode(target()->extra_ic_state())); |
655 // As must the contextual mode | |
656 ASSERT(GetContextualMode(code->extra_ic_state()) == | |
657 GetContextualMode(target()->extra_ic_state())); | |
666 IC::set_target(code); | 658 IC::set_target(code); |
667 } | 659 } |
668 | 660 |
669 static Handle<Code> initialize_stub(Isolate* isolate, | |
670 StrictModeFlag strict_mode) { | |
671 if (strict_mode == kStrictMode) { | |
672 return isolate->builtins()->StoreIC_Initialize_Strict(); | |
673 } else { | |
674 return isolate->builtins()->StoreIC_Initialize(); | |
675 } | |
676 } | |
677 | |
678 static void Clear(Isolate* isolate, Address address, Code* target); | 661 static void Clear(Isolate* isolate, Address address, Code* target); |
679 | 662 |
680 StrictModeFlag strict_mode_; | |
681 | |
682 friend class IC; | 663 friend class IC; |
683 }; | 664 }; |
684 | 665 |
685 | 666 |
686 enum KeyedStoreCheckMap { | 667 enum KeyedStoreCheckMap { |
687 kDontCheckMap, | 668 kDontCheckMap, |
688 kCheckMap | 669 kCheckMap |
689 }; | 670 }; |
690 | 671 |
691 | 672 |
692 enum KeyedStoreIncrementLength { | 673 enum KeyedStoreIncrementLength { |
693 kDontIncrementLength, | 674 kDontIncrementLength, |
694 kIncrementLength | 675 kIncrementLength |
695 }; | 676 }; |
696 | 677 |
697 | 678 |
698 class KeyedStoreIC: public StoreIC { | 679 class KeyedStoreIC: public StoreIC { |
699 public: | 680 public: |
700 // ExtraICState bits (building on IC) | 681 // ExtraICState bits (building on IC) |
701 // ExtraICState bits | 682 // ExtraICState bits |
702 class ExtraICStateKeyedAccessStoreMode: | 683 class ExtraICStateKeyedAccessStoreMode: |
703 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT | 684 public BitField<KeyedAccessStoreMode, 2, 4> {}; // NOLINT |
704 | 685 |
705 static ExtraICState ComputeExtraICState(StrictModeFlag flag, | 686 static ExtraICState ComputeExtraICState(StrictModeFlag flag, |
706 KeyedAccessStoreMode mode) { | 687 KeyedAccessStoreMode mode) { |
707 return StrictModeState::encode(flag) | | 688 return StrictModeState::encode(flag) | |
708 ExtraICStateKeyedAccessStoreMode::encode(mode); | 689 ExtraICStateKeyedAccessStoreMode::encode(mode); |
709 } | 690 } |
710 | 691 |
711 static KeyedAccessStoreMode GetKeyedAccessStoreMode( | 692 static KeyedAccessStoreMode GetKeyedAccessStoreMode( |
712 ExtraICState extra_state) { | 693 ExtraICState extra_state) { |
713 return ExtraICStateKeyedAccessStoreMode::decode(extra_state); | 694 return ExtraICStateKeyedAccessStoreMode::decode(extra_state); |
714 } | 695 } |
715 | 696 |
716 KeyedStoreIC(FrameDepth depth, Isolate* isolate) | 697 KeyedStoreIC(FrameDepth depth, Isolate* isolate) |
(...skipping 15 matching lines...) Expand all Loading... | |
732 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 713 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
733 StrictModeFlag strict_mode); | 714 StrictModeFlag strict_mode); |
734 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 715 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
735 static void GenerateNonStrictArguments(MacroAssembler* masm); | 716 static void GenerateNonStrictArguments(MacroAssembler* masm); |
736 | 717 |
737 protected: | 718 protected: |
738 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 719 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
739 | 720 |
740 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 721 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
741 | 722 |
742 virtual ExtraICState extra_ic_state() { | |
743 return ComputeExtraICState(strict_mode(), STANDARD_STORE); | |
744 } | |
745 | |
746 virtual Handle<Code> pre_monomorphic_stub() { | 723 virtual Handle<Code> pre_monomorphic_stub() { |
747 return pre_monomorphic_stub(isolate(), strict_mode()); | 724 return pre_monomorphic_stub(isolate(), strict_mode()); |
748 } | 725 } |
749 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 726 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
750 StrictModeFlag strict_mode) { | 727 StrictModeFlag strict_mode) { |
751 if (strict_mode == kStrictMode) { | 728 if (strict_mode == kStrictMode) { |
752 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); | 729 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); |
753 } else { | 730 } else { |
754 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 731 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
755 } | 732 } |
(...skipping 13 matching lines...) Expand all Loading... | |
769 KeyedAccessStoreMode store_mode); | 746 KeyedAccessStoreMode store_mode); |
770 | 747 |
771 private: | 748 private: |
772 void set_target(Code* code) { | 749 void set_target(Code* code) { |
773 // Strict mode must be preserved across IC patching. | 750 // Strict mode must be preserved across IC patching. |
774 ASSERT(GetStrictMode(code->extra_ic_state()) == strict_mode()); | 751 ASSERT(GetStrictMode(code->extra_ic_state()) == strict_mode()); |
775 IC::set_target(code); | 752 IC::set_target(code); |
776 } | 753 } |
777 | 754 |
778 // Stub accessors. | 755 // Stub accessors. |
779 static Handle<Code> initialize_stub(Isolate* isolate, | |
780 StrictModeFlag strict_mode) { | |
781 if (strict_mode == kStrictMode) { | |
782 return isolate->builtins()->KeyedStoreIC_Initialize_Strict(); | |
783 } else { | |
784 return isolate->builtins()->KeyedStoreIC_Initialize(); | |
785 } | |
786 } | |
787 | |
788 virtual Handle<Code> generic_stub() const { | 756 virtual Handle<Code> generic_stub() const { |
789 if (strict_mode() == kStrictMode) { | 757 if (strict_mode() == kStrictMode) { |
790 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 758 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
791 } else { | 759 } else { |
792 return isolate()->builtins()->KeyedStoreIC_Generic(); | 760 return isolate()->builtins()->KeyedStoreIC_Generic(); |
793 } | 761 } |
794 } | 762 } |
795 | 763 |
796 Handle<Code> non_strict_arguments_stub() { | 764 Handle<Code> non_strict_arguments_stub() { |
797 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 765 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1028 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); | 996 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); |
1029 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 997 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
1030 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 998 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
1031 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 999 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
1032 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 1000 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
1033 | 1001 |
1034 | 1002 |
1035 } } // namespace v8::internal | 1003 } } // namespace v8::internal |
1036 | 1004 |
1037 #endif // V8_IC_H_ | 1005 #endif // V8_IC_H_ |
OLD | NEW |