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