Chromium Code Reviews| 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 "macro-assembler.h" | 8 #include "macro-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 IC::UtilityId id() const { return id_; } | 326 IC::UtilityId id() const { return id_; } |
| 327 private: | 327 private: |
| 328 Address address_; | 328 Address address_; |
| 329 IC::UtilityId id_; | 329 IC::UtilityId id_; |
| 330 }; | 330 }; |
| 331 | 331 |
| 332 | 332 |
| 333 class CallIC: public IC { | 333 class CallIC: public IC { |
| 334 public: | 334 public: |
| 335 enum CallType { METHOD, FUNCTION }; | 335 enum CallType { METHOD, FUNCTION }; |
| 336 enum StubType { DEFAULT, MONOMORPHIC_ARRAY }; | |
| 336 | 337 |
| 337 class State V8_FINAL BASE_EMBEDDED { | 338 class State V8_FINAL BASE_EMBEDDED { |
| 338 public: | 339 public: |
| 339 explicit State(ExtraICState extra_ic_state); | 340 explicit State(ExtraICState extra_ic_state); |
| 340 | 341 |
| 341 static State DefaultCallState(int argc, CallType call_type) { | 342 static State MonomorphicArrayCallState(int argc, CallType call_type) { |
| 342 return State(argc, call_type); | 343 return State(argc, call_type, MONOMORPHIC_ARRAY); |
| 343 } | 344 } |
| 344 | 345 |
| 345 static State MegamorphicCallState(int argc, CallType call_type) { | 346 static State DefaultCallState(int argc, CallType call_type) { |
| 346 return State(argc, call_type); | 347 return State(argc, call_type, DEFAULT); |
| 347 } | 348 } |
| 348 | 349 |
| 349 InlineCacheState GetICState() const { return ::v8::internal::GENERIC; } | 350 // Transition from the current state to another. |
| 351 State ToGenericState() const { | |
| 352 return DefaultCallState(arg_count(), call_type()); | |
| 353 } | |
| 354 | |
| 355 State ToMonomorphicArrayCallState() const { | |
| 356 return MonomorphicArrayCallState(arg_count(), call_type()); | |
| 357 } | |
| 358 | |
| 359 InlineCacheState GetICState() const { | |
| 360 return stub_type_ == CallIC::DEFAULT | |
| 361 ? ::v8::internal::GENERIC | |
| 362 : ::v8::internal::MONOMORPHIC; | |
| 363 } | |
| 350 | 364 |
| 351 ExtraICState GetExtraICState() const; | 365 ExtraICState GetExtraICState() const; |
| 352 | 366 |
| 353 static void GenerateAheadOfTime( | 367 static void GenerateAheadOfTime( |
| 354 Isolate*, void (*Generate)(Isolate*, const State&)); | 368 Isolate*, void (*Generate)(Isolate*, const State&)); |
| 355 | 369 |
| 356 int arg_count() const { return argc_; } | 370 int arg_count() const { return argc_; } |
| 357 CallType call_type() const { return call_type_; } | 371 CallType call_type() const { return call_type_; } |
| 372 StubType stub_type() const { return stub_type_; } | |
| 358 | 373 |
| 359 bool CallAsMethod() const { return call_type_ == METHOD; } | 374 bool CallAsMethod() const { return call_type_ == METHOD; } |
| 360 | 375 |
| 361 void Print(StringStream* stream) const; | 376 void Print(StringStream* stream) const; |
| 362 | 377 |
| 363 bool operator==(const State& other_state) const { | 378 bool operator==(const State& other_state) const { |
| 364 return (argc_ == other_state.argc_ && | 379 return (argc_ == other_state.argc_ && |
| 365 call_type_ == other_state.call_type_); | 380 call_type_ == other_state.call_type_); |
| 366 } | 381 } |
| 367 | 382 |
| 368 bool operator!=(const State& other_state) const { | 383 bool operator!=(const State& other_state) const { |
| 369 return !(*this == other_state); | 384 return !(*this == other_state); |
| 370 } | 385 } |
| 371 | 386 |
| 372 private: | 387 private: |
| 373 State(int argc, | 388 State(int argc, |
| 374 CallType call_type) | 389 CallType call_type, |
|
danno
2014/05/16 16:34:11
fits on a single line?
mvstanton
2014/05/19 13:45:24
Done.
| |
| 390 StubType stub_type) | |
| 375 : argc_(argc), | 391 : argc_(argc), |
| 376 call_type_(call_type) { | 392 call_type_(call_type), |
| 393 stub_type_(stub_type) { | |
| 377 } | 394 } |
| 378 | 395 |
| 379 class ArgcBits: public BitField<int, 0, Code::kArgumentsBits> {}; | 396 class ArgcBits: public BitField<int, 0, Code::kArgumentsBits> {}; |
| 380 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {}; | 397 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {}; |
| 398 class StubTypeBits: | |
| 399 public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT | |
| 381 | 400 |
| 382 const int argc_; | 401 const int argc_; |
| 383 const CallType call_type_; | 402 const CallType call_type_; |
| 403 const StubType stub_type_; | |
| 384 }; | 404 }; |
| 385 | 405 |
| 386 explicit CallIC(Isolate* isolate) | 406 explicit CallIC(Isolate* isolate) |
| 387 : IC(EXTRA_CALL_FRAME, isolate) { | 407 : IC(EXTRA_CALL_FRAME, isolate) { |
| 388 } | 408 } |
| 389 | 409 |
| 390 void HandleMiss(Handle<Object> receiver, | 410 void HandleMiss(Handle<Object> receiver, |
| 391 Handle<Object> function, | 411 Handle<Object> function, |
| 392 Handle<FixedArray> vector, | 412 Handle<FixedArray> vector, |
| 393 Handle<Smi> slot); | 413 Handle<Smi> slot); |
| 394 | 414 |
| 415 // Returns true if a custom handler was installed. | |
| 416 bool DoCustomHandler(Handle<Object> receiver, | |
| 417 Handle<Object> function, | |
| 418 Handle<FixedArray> vector, | |
| 419 Handle<Smi> slot, | |
| 420 const State& new_state); | |
| 421 | |
| 395 // Code generator routines. | 422 // Code generator routines. |
| 396 static Handle<Code> initialize_stub(Isolate* isolate, | 423 static Handle<Code> initialize_stub(Isolate* isolate, |
| 397 int argc, | 424 int argc, |
| 398 CallType call_type); | 425 CallType call_type); |
| 399 | 426 |
| 400 static void Clear(Isolate* isolate, Address address, Code* target, | 427 static void Clear(Isolate* isolate, Address address, Code* target, |
| 401 ConstantPoolArray* constant_pool); | 428 ConstantPoolArray* constant_pool); |
| 402 }; | 429 }; |
| 403 | 430 |
| 404 | 431 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); | 1057 DECLARE_RUNTIME_FUNCTION(ElementsTransitionAndStoreIC_Miss); |
| 1031 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); | 1058 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_Miss); |
| 1032 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); | 1059 DECLARE_RUNTIME_FUNCTION(BinaryOpIC_MissWithAllocationSite); |
| 1033 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); | 1060 DECLARE_RUNTIME_FUNCTION(CompareNilIC_Miss); |
| 1034 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); | 1061 DECLARE_RUNTIME_FUNCTION(ToBooleanIC_Miss); |
| 1035 | 1062 |
| 1036 | 1063 |
| 1037 } } // namespace v8::internal | 1064 } } // namespace v8::internal |
| 1038 | 1065 |
| 1039 #endif // V8_IC_H_ | 1066 #endif // V8_IC_H_ |
| OLD | NEW |