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