Chromium Code Reviews| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 Code* pre_monomorphic_stub() { | 320 Code* pre_monomorphic_stub() { |
| 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 |
| 330 class KeyedIC: public IC { | |
| 331 public: | |
| 332 explicit KeyedIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) {} | |
| 333 virtual ~KeyedIC() {} | |
| 327 | 334 |
| 328 class KeyedLoadIC: public IC { | 335 static const int kMaxKeyedPolymorphism = 4; |
| 336 | |
| 337 virtual MaybeObject* ComputeMonomorphicBuiltinFastElementStub( | |
|
Mads Ager (chromium)
2011/05/10 13:38:06
Remove the Builtin from the name since it is not a
danno
2011/05/11 14:20:19
Done.
| |
| 338 bool is_js_array) = 0; | |
| 339 | |
| 340 virtual MaybeObject* ComputeMonomorphicBuiltinExternalArrayStub( | |
| 341 ExternalArrayType array_type) = 0; | |
| 342 | |
| 343 protected: | |
| 344 virtual Code* string_stub() { | |
| 345 return NULL; | |
| 346 } | |
| 347 | |
| 348 virtual Code::Kind kind() const = 0; | |
| 349 | |
| 350 virtual String* GetStubNameForCache(IC::State ic_state) = 0; | |
| 351 | |
| 352 MaybeObject* ComputeStub(JSObject* receiver, | |
| 353 bool is_store, | |
| 354 StrictModeFlag strict_mode, | |
| 355 Code* default_stub); | |
| 356 | |
| 357 virtual MaybeObject* ConstructMonomorphicFastElementStub( | |
| 358 Map* receiver_map, | |
| 359 StrictModeFlag strict_mode) = 0; | |
| 360 | |
| 361 virtual MaybeObject* ConstructMegamorphicStub( | |
| 362 MapList* receiver_maps, | |
| 363 CodeList* targets, | |
| 364 StrictModeFlag strict_mode) = 0; | |
| 365 | |
| 366 private: | |
| 367 void GetReceiverMapsForStub(Code* stub, MapList* result); | |
| 368 | |
| 369 MaybeObject* ComputeMonomorphicStubWithoutMapCheck( | |
| 370 Map* receiver_map, | |
| 371 StrictModeFlag strict_mode, | |
| 372 Code* generic_stub); | |
| 373 | |
| 374 MaybeObject* ComputeMonomorphicStub(JSObject* receiver, | |
| 375 bool is_store, | |
| 376 StrictModeFlag strict_mode, | |
| 377 Code* default_stub); | |
| 378 }; | |
| 379 | |
| 380 class KeyedLoadIC: public KeyedIC { | |
| 329 public: | 381 public: |
| 330 explicit KeyedLoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { | 382 explicit KeyedLoadIC(Isolate* isolate) : KeyedIC(isolate) { |
| 331 ASSERT(target()->is_keyed_load_stub() || | 383 ASSERT(target()->is_keyed_load_stub()); |
| 332 target()->is_external_array_load_stub()); | |
| 333 } | 384 } |
| 334 | 385 |
| 335 MUST_USE_RESULT MaybeObject* Load(State state, | 386 MUST_USE_RESULT MaybeObject* Load(State state, |
| 336 Handle<Object> object, | 387 Handle<Object> object, |
| 337 Handle<Object> key); | 388 Handle<Object> key, |
| 389 bool force_generic_stub); | |
| 338 | 390 |
| 339 // Code generator routines. | 391 // Code generator routines. |
| 340 static void GenerateMiss(MacroAssembler* masm); | 392 static void GenerateMiss(MacroAssembler* masm, bool force_generic); |
| 341 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 393 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 342 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 394 static void GenerateInitialize(MacroAssembler* masm) { |
| 395 GenerateMiss(masm, false); | |
| 396 } | |
| 343 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 397 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 344 GenerateMiss(masm); | 398 GenerateMiss(masm, false); |
| 345 } | 399 } |
| 346 static void GenerateGeneric(MacroAssembler* masm); | 400 static void GenerateGeneric(MacroAssembler* masm); |
| 347 static void GenerateString(MacroAssembler* masm); | 401 static void GenerateString(MacroAssembler* masm); |
| 348 | 402 |
| 349 static void GenerateIndexedInterceptor(MacroAssembler* masm); | 403 static void GenerateIndexedInterceptor(MacroAssembler* masm); |
| 350 | 404 |
| 351 // Bit mask to be tested against bit field for the cases when | 405 // Bit mask to be tested against bit field for the cases when |
| 352 // generic stub should go into slow case. | 406 // generic stub should go into slow case. |
| 353 // Access check is necessary explicitly since generic stub does not perform | 407 // Access check is necessary explicitly since generic stub does not perform |
| 354 // map checks. | 408 // map checks. |
| 355 static const int kSlowCaseBitFieldMask = | 409 static const int kSlowCaseBitFieldMask = |
| 356 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 410 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
| 357 | 411 |
| 412 virtual MaybeObject* ComputeMonomorphicBuiltinFastElementStub( | |
| 413 bool is_js_array); | |
| 414 | |
| 415 virtual MaybeObject* ComputeMonomorphicBuiltinExternalArrayStub( | |
| 416 ExternalArrayType array_type); | |
| 417 | |
| 418 protected: | |
| 419 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } | |
| 420 | |
| 421 virtual String* GetStubNameForCache(IC::State ic_state); | |
| 422 | |
| 423 virtual MaybeObject* ConstructMonomorphicFastElementStub( | |
| 424 Map* receiver_map, | |
| 425 StrictModeFlag strict_mode); | |
| 426 | |
| 427 virtual MaybeObject* ConstructMegamorphicStub( | |
| 428 MapList* receiver_maps, | |
| 429 CodeList* targets, | |
| 430 StrictModeFlag strict_mode); | |
| 431 | |
| 432 virtual Code* string_stub() { | |
| 433 return isolate()->builtins()->builtin( | |
| 434 Builtins::kKeyedLoadIC_String); | |
| 435 } | |
| 436 | |
| 358 private: | 437 private: |
| 359 // Update the inline cache. | 438 // Update the inline cache. |
| 360 void UpdateCaches(LookupResult* lookup, | 439 void UpdateCaches(LookupResult* lookup, |
| 361 State state, | 440 State state, |
| 362 Handle<Object> object, | 441 Handle<Object> object, |
| 363 Handle<String> name); | 442 Handle<String> name); |
| 364 | 443 |
| 365 // Stub accessors. | 444 // Stub accessors. |
| 366 static Code* initialize_stub() { | 445 static Code* initialize_stub() { |
| 367 return Isolate::Current()->builtins()->builtin( | 446 return Isolate::Current()->builtins()->builtin( |
| 368 Builtins::kKeyedLoadIC_Initialize); | 447 Builtins::kKeyedLoadIC_Initialize); |
| 369 } | 448 } |
| 370 Code* megamorphic_stub() { | 449 Code* megamorphic_stub() { |
| 371 return isolate()->builtins()->builtin( | 450 return isolate()->builtins()->builtin( |
| 372 Builtins::kKeyedLoadIC_Generic); | 451 Builtins::kKeyedLoadIC_Generic); |
| 373 } | 452 } |
| 374 Code* generic_stub() { | 453 Code* generic_stub() { |
| 375 return isolate()->builtins()->builtin( | 454 return isolate()->builtins()->builtin( |
| 376 Builtins::kKeyedLoadIC_Generic); | 455 Builtins::kKeyedLoadIC_Generic); |
| 377 } | 456 } |
| 378 Code* pre_monomorphic_stub() { | 457 Code* pre_monomorphic_stub() { |
| 379 return isolate()->builtins()->builtin( | 458 return isolate()->builtins()->builtin( |
| 380 Builtins::kKeyedLoadIC_PreMonomorphic); | 459 Builtins::kKeyedLoadIC_PreMonomorphic); |
| 381 } | 460 } |
| 382 Code* string_stub() { | |
| 383 return isolate()->builtins()->builtin( | |
| 384 Builtins::kKeyedLoadIC_String); | |
| 385 } | |
| 386 | |
| 387 Code* indexed_interceptor_stub() { | 461 Code* indexed_interceptor_stub() { |
| 388 return isolate()->builtins()->builtin( | 462 return isolate()->builtins()->builtin( |
| 389 Builtins::kKeyedLoadIC_IndexedInterceptor); | 463 Builtins::kKeyedLoadIC_IndexedInterceptor); |
| 390 } | 464 } |
| 391 | 465 |
| 392 static void Clear(Address address, Code* target); | 466 static void Clear(Address address, Code* target); |
| 393 | 467 |
| 394 friend class IC; | 468 friend class IC; |
| 395 }; | 469 }; |
| 396 | 470 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 return isolate()->builtins()->builtin( | 533 return isolate()->builtins()->builtin( |
| 460 Builtins::kStoreIC_GlobalProxy_Strict); | 534 Builtins::kStoreIC_GlobalProxy_Strict); |
| 461 } | 535 } |
| 462 | 536 |
| 463 static void Clear(Address address, Code* target); | 537 static void Clear(Address address, Code* target); |
| 464 | 538 |
| 465 friend class IC; | 539 friend class IC; |
| 466 }; | 540 }; |
| 467 | 541 |
| 468 | 542 |
| 469 class KeyedStoreIC: public IC { | 543 class KeyedStoreIC: public KeyedIC { |
| 470 public: | 544 public: |
| 471 explicit KeyedStoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 545 explicit KeyedStoreIC(Isolate* isolate) : KeyedIC(isolate) { |
| 546 ASSERT(target()->is_keyed_store_stub()); | |
| 547 } | |
| 472 | 548 |
| 473 MUST_USE_RESULT MaybeObject* Store(State state, | 549 MUST_USE_RESULT MaybeObject* Store(State state, |
| 474 StrictModeFlag strict_mode, | 550 StrictModeFlag strict_mode, |
| 475 Handle<Object> object, | 551 Handle<Object> object, |
| 476 Handle<Object> name, | 552 Handle<Object> name, |
| 477 Handle<Object> value); | 553 Handle<Object> value, |
| 554 bool force_generic); | |
| 478 | 555 |
| 479 // Code generators for stub routines. Only called once at startup. | 556 // Code generators for stub routines. Only called once at startup. |
| 480 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 557 static void GenerateInitialize(MacroAssembler* masm) { |
| 481 static void GenerateMiss(MacroAssembler* masm); | 558 GenerateMiss(masm, false); |
| 559 } | |
| 560 static void GenerateMiss(MacroAssembler* masm, bool force_generic); | |
| 561 static void GenerateSlow(MacroAssembler* masm); | |
| 482 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 562 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 483 StrictModeFlag strict_mode); | 563 StrictModeFlag strict_mode); |
| 484 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 564 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 485 | 565 |
| 486 private: | 566 virtual MaybeObject* ComputeMonomorphicBuiltinFastElementStub( |
| 567 bool is_js_array); | |
| 568 | |
| 569 virtual MaybeObject* ComputeMonomorphicBuiltinExternalArrayStub( | |
| 570 ExternalArrayType array_type); | |
| 571 | |
| 572 protected: | |
| 573 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | |
| 574 | |
| 575 virtual String* GetStubNameForCache(IC::State ic_state); | |
| 576 | |
| 577 virtual MaybeObject* ConstructMonomorphicFastElementStub( | |
| 578 Map* receiver_map, | |
| 579 StrictModeFlag strict_mode); | |
| 580 | |
| 581 virtual MaybeObject* ConstructMegamorphicStub( | |
| 582 MapList* receiver_maps, | |
| 583 CodeList* targets, | |
| 584 StrictModeFlag strict_mode); | |
| 585 | |
| 586 private: | |
| 487 // Update the inline cache. | 587 // Update the inline cache. |
| 488 void UpdateCaches(LookupResult* lookup, | 588 void UpdateCaches(LookupResult* lookup, |
| 489 State state, | 589 State state, |
| 490 StrictModeFlag strict_mode, | 590 StrictModeFlag strict_mode, |
| 491 Handle<JSObject> receiver, | 591 Handle<JSObject> receiver, |
| 492 Handle<String> name, | 592 Handle<String> name, |
| 493 Handle<Object> value); | 593 Handle<Object> value); |
| 494 | 594 |
| 495 void set_target(Code* code) { | 595 void set_target(Code* code) { |
| 496 // Strict mode must be preserved across IC patching. | 596 // Strict mode must be preserved across IC patching. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 | 725 |
| 626 Token::Value op_; | 726 Token::Value op_; |
| 627 }; | 727 }; |
| 628 | 728 |
| 629 // Helper for TRBinaryOpIC and CompareIC. | 729 // Helper for TRBinaryOpIC and CompareIC. |
| 630 void PatchInlinedSmiCode(Address address); | 730 void PatchInlinedSmiCode(Address address); |
| 631 | 731 |
| 632 } } // namespace v8::internal | 732 } } // namespace v8::internal |
| 633 | 733 |
| 634 #endif // V8_IC_H_ | 734 #endif // V8_IC_H_ |
| OLD | NEW |