| 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/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 static void Clear(Isolate* isolate, Address address, Code* target, | 373 static void Clear(Isolate* isolate, Address address, Code* target, |
| 374 ConstantPoolArray* constant_pool); | 374 ConstantPoolArray* constant_pool); |
| 375 }; | 375 }; |
| 376 | 376 |
| 377 | 377 |
| 378 OStream& operator<<(OStream& os, const CallIC::State& s); | 378 OStream& operator<<(OStream& os, const CallIC::State& s); |
| 379 | 379 |
| 380 | 380 |
| 381 class LoadIC: public IC { | 381 class LoadIC: public IC { |
| 382 public: | 382 public: |
| 383 // ExtraICState bits | |
| 384 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; | |
| 385 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); | |
| 386 | 383 |
| 387 enum ParameterIndices { | 384 enum ParameterIndices { |
| 388 kReceiverIndex, | 385 kReceiverIndex, |
| 389 kNameIndex, | 386 kNameIndex, |
| 390 kParameterCount | 387 kParameterCount |
| 391 }; | 388 }; |
| 392 static const Register ReceiverRegister(); | 389 static const Register ReceiverRegister(); |
| 393 static const Register NameRegister(); | 390 static const Register NameRegister(); |
| 394 | 391 |
| 395 // With flag vector-ics, there is an additional argument. And for calls from | 392 // With flag vector-ics, there is an additional argument. And for calls from |
| 396 // crankshaft, yet another. | 393 // crankshaft, yet another. |
| 397 static const Register SlotRegister(); | 394 static const Register SlotRegister(); |
| 398 static const Register VectorRegister(); | 395 static const Register VectorRegister(); |
| 399 | 396 |
| 400 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 397 class State V8_FINAL BASE_EMBEDDED { |
| 401 return ContextualModeBits::encode(contextual_mode); | 398 public: |
| 399 explicit State(ExtraICState extra_ic_state) |
| 400 : typeof_state_(TypeofStateBits::decode(extra_ic_state)) {} |
| 401 |
| 402 State(TypeofState typeof_state) : typeof_state_(typeof_state) {} |
| 403 |
| 404 ExtraICState GetExtraICState() const { |
| 405 return TypeofStateBits::encode(typeof_state_); |
| 406 } |
| 407 |
| 408 TypeofState typeof_state() const { |
| 409 return typeof_state_; |
| 410 } |
| 411 |
| 412 private: |
| 413 class TypeofStateBits: public BitField<TypeofState, 0, 1> {}; |
| 414 STATIC_ASSERT(static_cast<int>(INSIDE_TYPEOF) == 0); |
| 415 |
| 416 const TypeofState typeof_state_; |
| 417 }; |
| 418 |
| 419 static ExtraICState ComputeExtraICState(TypeofState typeof_state) { |
| 420 return State(typeof_state).GetExtraICState(); |
| 402 } | 421 } |
| 403 | 422 |
| 404 static ContextualMode GetContextualMode(ExtraICState state) { | 423 static TypeofState GetTypeofState(ExtraICState state) { |
| 405 return ContextualModeBits::decode(state); | 424 return State(state).typeof_state(); |
| 406 } | 425 } |
| 407 | 426 |
| 408 ContextualMode contextual_mode() const { | 427 TypeofState typeof_state() const { |
| 409 return ContextualModeBits::decode(extra_ic_state()); | 428 return GetTypeofState(extra_ic_state()); |
| 410 } | 429 } |
| 411 | 430 |
| 412 explicit LoadIC(FrameDepth depth, Isolate* isolate) | 431 explicit LoadIC(FrameDepth depth, Isolate* isolate) |
| 413 : IC(depth, isolate) { | 432 : IC(depth, isolate) { |
| 414 ASSERT(IsLoadStub()); | 433 ASSERT(IsLoadStub()); |
| 415 } | 434 } |
| 416 | 435 |
| 417 // Returns if this IC is for contextual (no explicit receiver) | 436 // Returns true if the receiver is the global object accessed outside of a |
| 418 // access to properties. | 437 // typeof scope. |
| 419 bool IsUndeclaredGlobal(Handle<Object> receiver) { | 438 bool IsUndeclaredGlobal(Handle<Object> receiver) { |
| 420 if (receiver->IsGlobalObject()) { | 439 if (receiver->IsGlobalObject()) { |
| 421 return contextual_mode() == CONTEXTUAL; | 440 return typeof_state() == NOT_INSIDE_TYPEOF; |
| 422 } else { | 441 } else { |
| 423 ASSERT(contextual_mode() != CONTEXTUAL); | 442 ASSERT(typeof_state() == INSIDE_TYPEOF); |
| 424 return false; | 443 return false; |
| 425 } | 444 } |
| 426 } | 445 } |
| 427 | 446 |
| 428 // Code generator routines. | 447 // Code generator routines. |
| 429 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 448 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 430 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 449 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 431 GenerateMiss(masm); | 450 GenerateMiss(masm); |
| 432 } | 451 } |
| 433 static void GenerateMiss(MacroAssembler* masm); | 452 static void GenerateMiss(MacroAssembler* masm); |
| 434 static void GenerateMegamorphic(MacroAssembler* masm); | 453 static void GenerateMegamorphic(MacroAssembler* masm); |
| 435 static void GenerateNormal(MacroAssembler* masm); | 454 static void GenerateNormal(MacroAssembler* masm); |
| 436 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 455 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 437 | 456 |
| 438 static Handle<Code> initialize_stub(Isolate* isolate, | 457 static Handle<Code> initialize_stub(Isolate* isolate, |
| 439 ExtraICState extra_state); | 458 ExtraICState extra_state); |
| 440 | 459 |
| 441 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 460 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
| 442 Handle<String> name); | 461 Handle<String> name); |
| 443 | 462 |
| 444 protected: | 463 protected: |
| 445 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 464 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 446 | 465 |
| 447 void set_target(Code* code) { | 466 void set_target(Code* code) { |
| 448 // The contextual mode must be preserved across IC patching. | 467 // The typeof state must be preserved across IC patching. |
| 449 ASSERT(GetContextualMode(code->extra_ic_state()) == | 468 ASSERT(GetTypeofState(code->extra_ic_state()) == |
| 450 GetContextualMode(target()->extra_ic_state())); | 469 GetTypeofState(target()->extra_ic_state())); |
| 451 | 470 |
| 452 IC::set_target(code); | 471 IC::set_target(code); |
| 453 } | 472 } |
| 454 | 473 |
| 455 virtual Handle<Code> slow_stub() const { | 474 virtual Handle<Code> slow_stub() const { |
| 456 return isolate()->builtins()->LoadIC_Slow(); | 475 return isolate()->builtins()->LoadIC_Slow(); |
| 457 } | 476 } |
| 458 | 477 |
| 459 virtual Handle<Code> megamorphic_stub(); | 478 virtual Handle<Code> megamorphic_stub(); |
| 460 virtual Handle<Code> generic_stub() const; | 479 virtual Handle<Code> generic_stub() const; |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); | 1054 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); |
| 1036 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); | 1055 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); |
| 1037 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); | 1056 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); |
| 1038 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); | 1057 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); |
| 1039 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); | 1058 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); |
| 1040 | 1059 |
| 1041 | 1060 |
| 1042 } } // namespace v8::internal | 1061 } } // namespace v8::internal |
| 1043 | 1062 |
| 1044 #endif // V8_IC_H_ | 1063 #endif // V8_IC_H_ |
| OLD | NEW |