OLD | NEW |
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/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 CallICState::CallType call_type); | 345 CallICState::CallType call_type); |
346 static Handle<Code> initialize_stub_in_optimized_code( | 346 static Handle<Code> initialize_stub_in_optimized_code( |
347 Isolate* isolate, int argc, CallICState::CallType call_type); | 347 Isolate* isolate, int argc, CallICState::CallType call_type); |
348 | 348 |
349 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus); | 349 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus); |
350 }; | 350 }; |
351 | 351 |
352 | 352 |
353 class LoadIC : public IC { | 353 class LoadIC : public IC { |
354 public: | 354 public: |
355 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 355 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, |
356 return LoadICState(contextual_mode).GetExtraICState(); | 356 LanguageMode language_mode) { |
| 357 return LoadICState(contextual_mode, language_mode).GetExtraICState(); |
357 } | 358 } |
358 | 359 |
359 ContextualMode contextual_mode() const { | 360 ContextualMode contextual_mode() const { |
360 return LoadICState::GetContextualMode(extra_ic_state()); | 361 return LoadICState::GetContextualMode(extra_ic_state()); |
361 } | 362 } |
362 | 363 |
| 364 LanguageMode language_mode() const { |
| 365 return LoadICState::GetLanguageMode(extra_ic_state()); |
| 366 } |
| 367 |
363 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) | 368 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) |
364 : IC(depth, isolate, nexus) { | 369 : IC(depth, isolate, nexus) { |
365 DCHECK(nexus != NULL); | 370 DCHECK(nexus != NULL); |
366 DCHECK(IsLoadStub()); | 371 DCHECK(IsLoadStub()); |
367 } | 372 } |
368 | 373 |
369 // TODO(mvstanton): The for_queries_only is because we have a case where we | 374 // TODO(mvstanton): The for_queries_only is because we have a case where we |
370 // construct an IC only to gather the contextual mode, and we don't have | 375 // construct an IC only to gather the contextual mode, and we don't have |
371 // vector/slot information. for_queries_only is a temporary hack to enable the | 376 // vector/slot information. for_queries_only is a temporary hack to enable the |
372 // strong DCHECK protection around vector/slot. | 377 // strong DCHECK protection around vector/slot. |
373 LoadIC(FrameDepth depth, Isolate* isolate, bool for_queries_only) | 378 LoadIC(FrameDepth depth, Isolate* isolate, bool for_queries_only) |
374 : IC(depth, isolate, NULL, for_queries_only) { | 379 : IC(depth, isolate, NULL, for_queries_only) { |
375 DCHECK(IsLoadStub()); | 380 DCHECK(IsLoadStub()); |
376 } | 381 } |
377 | 382 |
378 // Returns if this IC is for contextual (no explicit receiver) | 383 // Returns if this IC is for contextual (no explicit receiver) |
379 // access to properties. | 384 // access to properties. |
380 bool IsUndeclaredGlobal(Handle<Object> receiver) { | 385 bool IsUndeclaredGlobal(Handle<Object> receiver) { |
381 if (receiver->IsGlobalObject()) { | 386 if (receiver->IsGlobalObject()) { |
382 return contextual_mode() == CONTEXTUAL; | 387 return contextual_mode() == CONTEXTUAL; |
383 } else { | 388 } else { |
384 DCHECK(contextual_mode() != CONTEXTUAL); | 389 DCHECK(contextual_mode() != CONTEXTUAL); |
385 return false; | 390 return false; |
386 } | 391 } |
387 } | 392 } |
388 | 393 |
389 // Code generator routines. | 394 // Code generator routines. |
390 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 395 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
391 static void GenerateMiss(MacroAssembler* masm); | 396 static void GenerateMiss(MacroAssembler* masm); |
392 static void GenerateNormal(MacroAssembler* masm); | 397 static void GenerateRuntimeGetProperty(MacroAssembler* masm, |
393 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 398 LanguageMode language_mode); |
| 399 static void GenerateNormal(MacroAssembler* masm, LanguageMode language_mode); |
394 | 400 |
395 static Handle<Code> initialize_stub(Isolate* isolate, | 401 static Handle<Code> initialize_stub(Isolate* isolate, |
396 ExtraICState extra_state); | 402 ExtraICState extra_state); |
397 static Handle<Code> initialize_stub_in_optimized_code( | 403 static Handle<Code> initialize_stub_in_optimized_code( |
398 Isolate* isolate, ExtraICState extra_state, State initialization_state); | 404 Isolate* isolate, ExtraICState extra_state, State initialization_state); |
399 | 405 |
400 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 406 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
401 Handle<Name> name); | 407 Handle<Name> name); |
402 | 408 |
403 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); | 409 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); |
404 | 410 |
405 protected: | 411 protected: |
406 inline void set_target(Code* code); | 412 inline void set_target(Code* code); |
407 | 413 |
408 Handle<Code> slow_stub() const { | 414 Handle<Code> slow_stub() const { |
409 if (kind() == Code::LOAD_IC) { | 415 if (kind() == Code::LOAD_IC) { |
410 return isolate()->builtins()->LoadIC_Slow(); | 416 return is_strong(language_mode()) |
| 417 ? isolate()->builtins()->LoadIC_Slow_Strong() |
| 418 : isolate()->builtins()->LoadIC_Slow(); |
411 } else { | 419 } else { |
412 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); | 420 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); |
413 return isolate()->builtins()->KeyedLoadIC_Slow(); | 421 return is_strong(language_mode()) |
| 422 ? isolate()->builtins()->KeyedLoadIC_Slow_Strong() |
| 423 : isolate()->builtins()->KeyedLoadIC_Slow(); |
414 } | 424 } |
415 } | 425 } |
416 | 426 |
417 Handle<Code> megamorphic_stub() override; | 427 Handle<Code> megamorphic_stub() override; |
418 | 428 |
419 // Update the inline cache and the global stub cache based on the | 429 // Update the inline cache and the global stub cache based on the |
420 // lookup result. | 430 // lookup result. |
421 void UpdateCaches(LookupIterator* lookup); | 431 void UpdateCaches(LookupIterator* lookup); |
422 | 432 |
423 virtual Handle<Code> CompileHandler(LookupIterator* lookup, | 433 virtual Handle<Code> CompileHandler(LookupIterator* lookup, |
424 Handle<Object> unused, | 434 Handle<Object> unused, |
425 CacheHolderFlag cache_holder) override; | 435 CacheHolderFlag cache_holder) override; |
426 | 436 |
427 private: | 437 private: |
428 Handle<Code> SimpleFieldLoad(FieldIndex index); | 438 Handle<Code> SimpleFieldLoad(FieldIndex index); |
429 | 439 |
430 static void Clear(Isolate* isolate, Address address, Code* target, | 440 static void Clear(Isolate* isolate, Address address, Code* target, |
431 Address constant_pool); | 441 Address constant_pool); |
432 | 442 |
433 friend class IC; | 443 friend class IC; |
434 }; | 444 }; |
435 | 445 |
436 | 446 |
437 class KeyedLoadIC : public LoadIC { | 447 class KeyedLoadIC : public LoadIC { |
438 public: | 448 public: |
439 // ExtraICState bits (building on IC) | 449 // ExtraICState bits (building on IC) |
440 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; | 450 class IcCheckTypeField |
| 451 : public BitField<IcCheckType, LoadICState::kNextBitFieldOffset, 1> {}; |
441 | 452 |
442 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, | 453 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, |
| 454 LanguageMode language_mode, |
443 IcCheckType key_type) { | 455 IcCheckType key_type) { |
444 return LoadICState(contextual_mode).GetExtraICState() | | 456 return LoadICState(contextual_mode, language_mode).GetExtraICState() | |
445 IcCheckTypeField::encode(key_type); | 457 IcCheckTypeField::encode(key_type); |
446 } | 458 } |
447 | 459 |
448 static IcCheckType GetKeyType(ExtraICState extra_state) { | 460 static IcCheckType GetKeyType(ExtraICState extra_state) { |
449 return IcCheckTypeField::decode(extra_state); | 461 return IcCheckTypeField::decode(extra_state); |
450 } | 462 } |
451 | 463 |
452 KeyedLoadIC(FrameDepth depth, Isolate* isolate, | 464 KeyedLoadIC(FrameDepth depth, Isolate* isolate, |
453 KeyedLoadICNexus* nexus = NULL) | 465 KeyedLoadICNexus* nexus = NULL) |
454 : LoadIC(depth, isolate, nexus) { | 466 : LoadIC(depth, isolate, nexus) { |
455 DCHECK(nexus != NULL); | 467 DCHECK(nexus != NULL); |
456 DCHECK(target()->is_keyed_load_stub()); | 468 DCHECK(target()->is_keyed_load_stub()); |
457 } | 469 } |
458 | 470 |
459 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 471 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
460 Handle<Object> key); | 472 Handle<Object> key); |
461 | 473 |
462 // Code generator routines. | 474 // Code generator routines. |
463 static void GenerateMiss(MacroAssembler* masm); | 475 static void GenerateMiss(MacroAssembler* masm); |
464 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 476 static void GenerateRuntimeGetProperty(MacroAssembler* masm, |
| 477 LanguageMode language_mode); |
465 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 478 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
466 static void GenerateMegamorphic(MacroAssembler* masm); | 479 static void GenerateMegamorphic(MacroAssembler* masm, |
| 480 LanguageMode language_mode); |
467 | 481 |
468 // Bit mask to be tested against bit field for the cases when | 482 // Bit mask to be tested against bit field for the cases when |
469 // generic stub should go into slow case. | 483 // generic stub should go into slow case. |
470 // Access check is necessary explicitly since generic stub does not perform | 484 // Access check is necessary explicitly since generic stub does not perform |
471 // map checks. | 485 // map checks. |
472 static const int kSlowCaseBitFieldMask = | 486 static const int kSlowCaseBitFieldMask = |
473 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 487 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
474 | 488 |
475 static Handle<Code> initialize_stub(Isolate* isolate); | 489 static Handle<Code> initialize_stub(Isolate* isolate, |
| 490 ExtraICState extra_state); |
476 static Handle<Code> initialize_stub_in_optimized_code( | 491 static Handle<Code> initialize_stub_in_optimized_code( |
477 Isolate* isolate, State initialization_state); | 492 Isolate* isolate, State initialization_state, ExtraICState extra_state); |
478 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate); | 493 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate, |
| 494 ExtraICState extra_state); |
479 | 495 |
480 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus); | 496 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus); |
481 | 497 |
482 protected: | 498 protected: |
483 // receiver is HeapObject because it could be a String or a JSObject | 499 // receiver is HeapObject because it could be a String or a JSObject |
484 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); | 500 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); |
485 | 501 |
486 private: | 502 private: |
487 static void Clear(Isolate* isolate, Address address, Code* target, | 503 static void Clear(Isolate* isolate, Address address, Code* target, |
488 Address constant_pool); | 504 Address constant_pool); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 757 |
742 // Support functions for interceptor handlers. | 758 // Support functions for interceptor handlers. |
743 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | 759 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); |
744 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | 760 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); |
745 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | 761 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); |
746 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | 762 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); |
747 } | 763 } |
748 } // namespace v8::internal | 764 } // namespace v8::internal |
749 | 765 |
750 #endif // V8_IC_H_ | 766 #endif // V8_IC_H_ |
OLD | NEW |