OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 20 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 | 36 |
37 // IC_UTIL_LIST defines all utility functions called from generated | 37 // IC_UTIL_LIST defines all utility functions called from generated |
38 // inline caching code. The argument for the macro, ICU, is the function name. | 38 // inline caching code. The argument for the macro, ICU, is the function name. |
39 #define IC_UTIL_LIST(ICU) \ | 39 #define IC_UTIL_LIST(ICU) \ |
40 ICU(LoadIC_Miss) \ | 40 ICU(LoadIC_Miss) \ |
41 ICU(KeyedLoadIC_Miss) \ | 41 ICU(KeyedLoadIC_Miss) \ |
| 42 ICU(KeyedLoadIC_MissForceGeneric) \ |
42 ICU(CallIC_Miss) \ | 43 ICU(CallIC_Miss) \ |
43 ICU(KeyedCallIC_Miss) \ | 44 ICU(KeyedCallIC_Miss) \ |
44 ICU(StoreIC_Miss) \ | 45 ICU(StoreIC_Miss) \ |
45 ICU(StoreIC_ArrayLength) \ | 46 ICU(StoreIC_ArrayLength) \ |
46 ICU(SharedStoreIC_ExtendStorage) \ | 47 ICU(SharedStoreIC_ExtendStorage) \ |
47 ICU(KeyedStoreIC_Miss) \ | 48 ICU(KeyedStoreIC_Miss) \ |
| 49 ICU(KeyedStoreIC_MissForceGeneric) \ |
| 50 ICU(KeyedStoreIC_Slow) \ |
48 /* Utilities for IC stubs. */ \ | 51 /* Utilities for IC stubs. */ \ |
49 ICU(LoadCallbackProperty) \ | 52 ICU(LoadCallbackProperty) \ |
50 ICU(StoreCallbackProperty) \ | 53 ICU(StoreCallbackProperty) \ |
51 ICU(LoadPropertyWithInterceptorOnly) \ | 54 ICU(LoadPropertyWithInterceptorOnly) \ |
52 ICU(LoadPropertyWithInterceptorForLoad) \ | 55 ICU(LoadPropertyWithInterceptorForLoad) \ |
53 ICU(LoadPropertyWithInterceptorForCall) \ | 56 ICU(LoadPropertyWithInterceptorForCall) \ |
54 ICU(KeyedLoadPropertyWithInterceptor) \ | 57 ICU(KeyedLoadPropertyWithInterceptor) \ |
55 ICU(StoreInterceptorProperty) \ | 58 ICU(StoreInterceptorProperty) \ |
56 ICU(TypeRecordingUnaryOp_Patch) \ | 59 ICU(TypeRecordingUnaryOp_Patch) \ |
57 ICU(TypeRecordingBinaryOp_Patch) \ | 60 ICU(TypeRecordingBinaryOp_Patch) \ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 #ifdef ENABLE_DEBUGGER_SUPPORT | 138 #ifdef ENABLE_DEBUGGER_SUPPORT |
136 // Computes the address in the original code when the code running is | 139 // Computes the address in the original code when the code running is |
137 // containing break points (calls to DebugBreakXXX builtins). | 140 // containing break points (calls to DebugBreakXXX builtins). |
138 Address OriginalCodeAddress(); | 141 Address OriginalCodeAddress(); |
139 #endif | 142 #endif |
140 | 143 |
141 // Set the call-site target. | 144 // Set the call-site target. |
142 void set_target(Code* code) { SetTargetAtAddress(address(), code); } | 145 void set_target(Code* code) { SetTargetAtAddress(address(), code); } |
143 | 146 |
144 #ifdef DEBUG | 147 #ifdef DEBUG |
145 static void TraceIC(const char* type, | 148 void TraceIC(const char* type, |
146 Handle<Object> name, | 149 Handle<Object> name, |
147 State old_state, | 150 State old_state, |
148 Code* new_target, | 151 Code* new_target, |
149 const char* extra_info = ""); | 152 const char* extra_info = ""); |
150 #endif | 153 #endif |
151 | 154 |
152 Failure* TypeError(const char* type, | 155 Failure* TypeError(const char* type, |
153 Handle<Object> object, | 156 Handle<Object> object, |
154 Handle<Object> key); | 157 Handle<Object> key); |
155 Failure* ReferenceError(const char* type, Handle<String> name); | 158 Failure* ReferenceError(const char* type, Handle<String> name); |
156 | 159 |
157 // Access the target code for the given IC address. | 160 // Access the target code for the given IC address. |
158 static inline Code* GetTargetAtAddress(Address address); | 161 static inline Code* GetTargetAtAddress(Address address); |
159 static inline void SetTargetAtAddress(Address address, Code* target); | 162 static inline void SetTargetAtAddress(Address address, Code* target); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 return isolate()->builtins()->builtin( | 321 return isolate()->builtins()->builtin( |
319 Builtins::kLoadIC_PreMonomorphic); | 322 Builtins::kLoadIC_PreMonomorphic); |
320 } | 323 } |
321 | 324 |
322 static void Clear(Address address, Code* target); | 325 static void Clear(Address address, Code* target); |
323 | 326 |
324 friend class IC; | 327 friend class IC; |
325 }; | 328 }; |
326 | 329 |
327 | 330 |
328 class KeyedLoadIC: public IC { | 331 class KeyedIC: public IC { |
329 public: | 332 public: |
330 explicit KeyedLoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { | 333 explicit KeyedIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) {} |
331 ASSERT(target()->is_keyed_load_stub() || | 334 virtual ~KeyedIC() {} |
332 target()->is_external_array_load_stub()); | 335 |
| 336 static const int kMaxKeyedPolymorphism = 4; |
| 337 |
| 338 virtual MaybeObject* GetFastElementStubWithoutMapCheck( |
| 339 bool is_js_array) = 0; |
| 340 |
| 341 virtual MaybeObject* GetExternalArrayStubWithoutMapCheck( |
| 342 ExternalArrayType array_type) = 0; |
| 343 |
| 344 protected: |
| 345 virtual Code* string_stub() { |
| 346 return NULL; |
| 347 } |
| 348 |
| 349 virtual Code::Kind kind() const = 0; |
| 350 |
| 351 virtual String* GetStubNameForCache(IC::State ic_state) = 0; |
| 352 |
| 353 MaybeObject* ComputeStub(JSObject* receiver, |
| 354 bool is_store, |
| 355 StrictModeFlag strict_mode, |
| 356 Code* default_stub); |
| 357 |
| 358 virtual MaybeObject* ConstructMegamorphicStub( |
| 359 MapList* receiver_maps, |
| 360 CodeList* targets, |
| 361 StrictModeFlag strict_mode) = 0; |
| 362 |
| 363 private: |
| 364 void GetReceiverMapsForStub(Code* stub, MapList* result); |
| 365 |
| 366 MaybeObject* ComputeMonomorphicStubWithoutMapCheck( |
| 367 Map* receiver_map, |
| 368 StrictModeFlag strict_mode, |
| 369 Code* generic_stub); |
| 370 |
| 371 MaybeObject* ComputeMonomorphicStub(JSObject* receiver, |
| 372 bool is_store, |
| 373 StrictModeFlag strict_mode, |
| 374 Code* default_stub); |
| 375 }; |
| 376 |
| 377 |
| 378 class KeyedLoadIC: public KeyedIC { |
| 379 public: |
| 380 explicit KeyedLoadIC(Isolate* isolate) : KeyedIC(isolate) { |
| 381 ASSERT(target()->is_keyed_load_stub()); |
333 } | 382 } |
334 | 383 |
335 MUST_USE_RESULT MaybeObject* Load(State state, | 384 MUST_USE_RESULT MaybeObject* Load(State state, |
336 Handle<Object> object, | 385 Handle<Object> object, |
337 Handle<Object> key); | 386 Handle<Object> key, |
| 387 bool force_generic_stub); |
338 | 388 |
339 // Code generator routines. | 389 // Code generator routines. |
340 static void GenerateMiss(MacroAssembler* masm); | 390 static void GenerateMiss(MacroAssembler* masm, bool force_generic); |
341 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 391 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
342 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 392 static void GenerateInitialize(MacroAssembler* masm) { |
| 393 GenerateMiss(masm, false); |
| 394 } |
343 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 395 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
344 GenerateMiss(masm); | 396 GenerateMiss(masm, false); |
345 } | 397 } |
346 static void GenerateGeneric(MacroAssembler* masm); | 398 static void GenerateGeneric(MacroAssembler* masm); |
347 static void GenerateString(MacroAssembler* masm); | 399 static void GenerateString(MacroAssembler* masm); |
348 | 400 |
349 static void GenerateIndexedInterceptor(MacroAssembler* masm); | 401 static void GenerateIndexedInterceptor(MacroAssembler* masm); |
350 | 402 |
351 // Bit mask to be tested against bit field for the cases when | 403 // Bit mask to be tested against bit field for the cases when |
352 // generic stub should go into slow case. | 404 // generic stub should go into slow case. |
353 // Access check is necessary explicitly since generic stub does not perform | 405 // Access check is necessary explicitly since generic stub does not perform |
354 // map checks. | 406 // map checks. |
355 static const int kSlowCaseBitFieldMask = | 407 static const int kSlowCaseBitFieldMask = |
356 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 408 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
357 | 409 |
| 410 virtual MaybeObject* GetFastElementStubWithoutMapCheck( |
| 411 bool is_js_array); |
| 412 |
| 413 virtual MaybeObject* GetExternalArrayStubWithoutMapCheck( |
| 414 ExternalArrayType array_type); |
| 415 |
| 416 protected: |
| 417 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } |
| 418 |
| 419 virtual String* GetStubNameForCache(IC::State ic_state); |
| 420 |
| 421 virtual MaybeObject* ConstructMegamorphicStub( |
| 422 MapList* receiver_maps, |
| 423 CodeList* targets, |
| 424 StrictModeFlag strict_mode); |
| 425 |
| 426 virtual Code* string_stub() { |
| 427 return isolate()->builtins()->builtin( |
| 428 Builtins::kKeyedLoadIC_String); |
| 429 } |
| 430 |
358 private: | 431 private: |
359 // Update the inline cache. | 432 // Update the inline cache. |
360 void UpdateCaches(LookupResult* lookup, | 433 void UpdateCaches(LookupResult* lookup, |
361 State state, | 434 State state, |
362 Handle<Object> object, | 435 Handle<Object> object, |
363 Handle<String> name); | 436 Handle<String> name); |
364 | 437 |
365 // Stub accessors. | 438 // Stub accessors. |
366 static Code* initialize_stub() { | 439 static Code* initialize_stub() { |
367 return Isolate::Current()->builtins()->builtin( | 440 return Isolate::Current()->builtins()->builtin( |
368 Builtins::kKeyedLoadIC_Initialize); | 441 Builtins::kKeyedLoadIC_Initialize); |
369 } | 442 } |
370 Code* megamorphic_stub() { | 443 Code* megamorphic_stub() { |
371 return isolate()->builtins()->builtin( | 444 return isolate()->builtins()->builtin( |
372 Builtins::kKeyedLoadIC_Generic); | 445 Builtins::kKeyedLoadIC_Generic); |
373 } | 446 } |
374 Code* generic_stub() { | 447 Code* generic_stub() { |
375 return isolate()->builtins()->builtin( | 448 return isolate()->builtins()->builtin( |
376 Builtins::kKeyedLoadIC_Generic); | 449 Builtins::kKeyedLoadIC_Generic); |
377 } | 450 } |
378 Code* pre_monomorphic_stub() { | 451 Code* pre_monomorphic_stub() { |
379 return isolate()->builtins()->builtin( | 452 return isolate()->builtins()->builtin( |
380 Builtins::kKeyedLoadIC_PreMonomorphic); | 453 Builtins::kKeyedLoadIC_PreMonomorphic); |
381 } | 454 } |
382 Code* string_stub() { | |
383 return isolate()->builtins()->builtin( | |
384 Builtins::kKeyedLoadIC_String); | |
385 } | |
386 | |
387 Code* indexed_interceptor_stub() { | 455 Code* indexed_interceptor_stub() { |
388 return isolate()->builtins()->builtin( | 456 return isolate()->builtins()->builtin( |
389 Builtins::kKeyedLoadIC_IndexedInterceptor); | 457 Builtins::kKeyedLoadIC_IndexedInterceptor); |
390 } | 458 } |
391 | 459 |
392 static void Clear(Address address, Code* target); | 460 static void Clear(Address address, Code* target); |
393 | 461 |
394 friend class IC; | 462 friend class IC; |
395 }; | 463 }; |
396 | 464 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 return isolate()->builtins()->builtin( | 527 return isolate()->builtins()->builtin( |
460 Builtins::kStoreIC_GlobalProxy_Strict); | 528 Builtins::kStoreIC_GlobalProxy_Strict); |
461 } | 529 } |
462 | 530 |
463 static void Clear(Address address, Code* target); | 531 static void Clear(Address address, Code* target); |
464 | 532 |
465 friend class IC; | 533 friend class IC; |
466 }; | 534 }; |
467 | 535 |
468 | 536 |
469 class KeyedStoreIC: public IC { | 537 class KeyedStoreIC: public KeyedIC { |
470 public: | 538 public: |
471 explicit KeyedStoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 539 explicit KeyedStoreIC(Isolate* isolate) : KeyedIC(isolate) { |
| 540 ASSERT(target()->is_keyed_store_stub()); |
| 541 } |
472 | 542 |
473 MUST_USE_RESULT MaybeObject* Store(State state, | 543 MUST_USE_RESULT MaybeObject* Store(State state, |
474 StrictModeFlag strict_mode, | 544 StrictModeFlag strict_mode, |
475 Handle<Object> object, | 545 Handle<Object> object, |
476 Handle<Object> name, | 546 Handle<Object> name, |
477 Handle<Object> value); | 547 Handle<Object> value, |
| 548 bool force_generic); |
478 | 549 |
479 // Code generators for stub routines. Only called once at startup. | 550 // Code generators for stub routines. Only called once at startup. |
480 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 551 static void GenerateInitialize(MacroAssembler* masm) { |
481 static void GenerateMiss(MacroAssembler* masm); | 552 GenerateMiss(masm, false); |
| 553 } |
| 554 static void GenerateMiss(MacroAssembler* masm, bool force_generic); |
| 555 static void GenerateSlow(MacroAssembler* masm); |
482 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 556 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
483 StrictModeFlag strict_mode); | 557 StrictModeFlag strict_mode); |
484 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 558 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
485 | 559 |
486 private: | 560 virtual MaybeObject* GetFastElementStubWithoutMapCheck( |
| 561 bool is_js_array); |
| 562 |
| 563 virtual MaybeObject* GetExternalArrayStubWithoutMapCheck( |
| 564 ExternalArrayType array_type); |
| 565 |
| 566 protected: |
| 567 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 568 |
| 569 virtual String* GetStubNameForCache(IC::State ic_state); |
| 570 |
| 571 virtual MaybeObject* ConstructMegamorphicStub( |
| 572 MapList* receiver_maps, |
| 573 CodeList* targets, |
| 574 StrictModeFlag strict_mode); |
| 575 |
| 576 private: |
487 // Update the inline cache. | 577 // Update the inline cache. |
488 void UpdateCaches(LookupResult* lookup, | 578 void UpdateCaches(LookupResult* lookup, |
489 State state, | 579 State state, |
490 StrictModeFlag strict_mode, | 580 StrictModeFlag strict_mode, |
491 Handle<JSObject> receiver, | 581 Handle<JSObject> receiver, |
492 Handle<String> name, | 582 Handle<String> name, |
493 Handle<Object> value); | 583 Handle<Object> value); |
494 | 584 |
495 void set_target(Code* code) { | 585 void set_target(Code* code) { |
496 // Strict mode must be preserved across IC patching. | 586 // Strict mode must be preserved across IC patching. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 715 |
626 Token::Value op_; | 716 Token::Value op_; |
627 }; | 717 }; |
628 | 718 |
629 // Helper for TRBinaryOpIC and CompareIC. | 719 // Helper for TRBinaryOpIC and CompareIC. |
630 void PatchInlinedSmiCode(Address address); | 720 void PatchInlinedSmiCode(Address address); |
631 | 721 |
632 } } // namespace v8::internal | 722 } } // namespace v8::internal |
633 | 723 |
634 #endif // V8_IC_H_ | 724 #endif // V8_IC_H_ |
OLD | NEW |