 Chromium Code Reviews
 Chromium Code Reviews Issue 6576024:
  (early draft) Strict mode - throw exception on assignment to read only property.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 6576024:
  (early draft) Strict mode - throw exception on assignment to read only property.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 | 
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 // Support for patching the map that is checked in an inlined | 391 // Support for patching the map that is checked in an inlined | 
| 392 // version of keyed load. | 392 // version of keyed load. | 
| 393 static bool PatchInlinedLoad(Address address, Object* map); | 393 static bool PatchInlinedLoad(Address address, Object* map); | 
| 394 | 394 | 
| 395 friend class IC; | 395 friend class IC; | 
| 396 }; | 396 }; | 
| 397 | 397 | 
| 398 | 398 | 
| 399 class StoreIC: public IC { | 399 class StoreIC: public IC { | 
| 400 public: | 400 public: | 
| 401 | |
| 402 enum StoreICStrictMode { | |
| 403 kStoreICNonStrict = kNonStrictMode, | |
| 404 kStoreICStrict = kStrictMode | |
| 405 }; | |
| 406 | |
| 
Martin Maly
2011/02/24 06:33:34
I'd have to clone this enum for KeyedStoreIC also,
 | |
| 407 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } | 401 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } | 
| 408 | 402 | 
| 409 MUST_USE_RESULT MaybeObject* Store(State state, | 403 MUST_USE_RESULT MaybeObject* Store(State state, | 
| 410 Code::ExtraICState extra_ic_state, | 404 Code::ExtraICState extra_ic_state, | 
| 411 Handle<Object> object, | 405 Handle<Object> object, | 
| 412 Handle<String> name, | 406 Handle<String> name, | 
| 413 Handle<Object> value); | 407 Handle<Object> value); | 
| 414 | 408 | 
| 415 // Code generators for stub routines. Only called once at startup. | 409 // Code generators for stub routines. Only called once at startup. | 
| 416 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 410 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 
| 417 static void GenerateMiss(MacroAssembler* masm); | 411 static void GenerateMiss(MacroAssembler* masm); | 
| 418 static void GenerateMegamorphic(MacroAssembler* masm, | 412 static void GenerateMegamorphic(MacroAssembler* masm, | 
| 419 Code::ExtraICState extra_ic_state); | 413 Code::ExtraICState extra_ic_state); | 
| 420 static void GenerateArrayLength(MacroAssembler* masm); | 414 static void GenerateArrayLength(MacroAssembler* masm); | 
| 421 static void GenerateNormal(MacroAssembler* masm); | 415 static void GenerateNormal(MacroAssembler* masm); | 
| 422 static void GenerateGlobalProxy(MacroAssembler* masm); | 416 static void GenerateGlobalProxy(MacroAssembler* masm, StrictModeFlag strict); | 
| 423 | 417 | 
| 424 // Clear the use of an inlined version. | 418 // Clear the use of an inlined version. | 
| 425 static void ClearInlinedVersion(Address address); | 419 static void ClearInlinedVersion(Address address); | 
| 426 | 420 | 
| 427 // The offset from the inlined patch site to the start of the | 421 // The offset from the inlined patch site to the start of the | 
| 428 // inlined store instruction. | 422 // inlined store instruction. | 
| 429 static const int kOffsetToStoreInstruction; | 423 static const int kOffsetToStoreInstruction; | 
| 430 | 424 | 
| 431 private: | 425 private: | 
| 432 // Update the inline cache and the global stub cache based on the | 426 // Update the inline cache and the global stub cache based on the | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 | 460 | 
| 467 friend class IC; | 461 friend class IC; | 
| 468 }; | 462 }; | 
| 469 | 463 | 
| 470 | 464 | 
| 471 class KeyedStoreIC: public IC { | 465 class KeyedStoreIC: public IC { | 
| 472 public: | 466 public: | 
| 473 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } | 467 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } | 
| 474 | 468 | 
| 475 MUST_USE_RESULT MaybeObject* Store(State state, | 469 MUST_USE_RESULT MaybeObject* Store(State state, | 
| 470 Code::ExtraICState extra_ic_state, | |
| 476 Handle<Object> object, | 471 Handle<Object> object, | 
| 477 Handle<Object> name, | 472 Handle<Object> name, | 
| 478 Handle<Object> value); | 473 Handle<Object> value); | 
| 479 | 474 | 
| 480 // Code generators for stub routines. Only called once at startup. | 475 // Code generators for stub routines. Only called once at startup. | 
| 481 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 476 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 
| 482 static void GenerateMiss(MacroAssembler* masm); | 477 static void GenerateMiss(MacroAssembler* masm); | 
| 483 static void GenerateRuntimeSetProperty(MacroAssembler* masm); | 478 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 
| 484 static void GenerateGeneric(MacroAssembler* masm); | 479 StrictModeFlag strict_mode); | 
| 480 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | |
| 485 | 481 | 
| 486 // Clear the inlined version so the IC is always hit. | 482 // Clear the inlined version so the IC is always hit. | 
| 487 static void ClearInlinedVersion(Address address); | 483 static void ClearInlinedVersion(Address address); | 
| 488 | 484 | 
| 489 // Restore the inlined version so the fast case can get hit. | 485 // Restore the inlined version so the fast case can get hit. | 
| 490 static void RestoreInlinedVersion(Address address); | 486 static void RestoreInlinedVersion(Address address); | 
| 491 | 487 | 
| 492 private: | 488 private: | 
| 493 // Update the inline cache. | 489 // Update the inline cache. | 
| 494 void UpdateCaches(LookupResult* lookup, | 490 void UpdateCaches(LookupResult* lookup, | 
| 495 State state, | 491 State state, | 
| 496 Handle<JSObject> receiver, | 492 Handle<JSObject> receiver, | 
| 497 Handle<String> name, | 493 Handle<String> name, | 
| 498 Handle<Object> value); | 494 Handle<Object> value); | 
| 499 | 495 | 
| 500 // Stub accessors. | 496 // Stub accessors. | 
| 501 static Code* initialize_stub() { | 497 static Code* initialize_stub() { | 
| 502 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); | 498 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); | 
| 503 } | 499 } | 
| 500 static Code* initialize_stub_strict() { | |
| 501 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize_Strict); | |
| 502 } | |
| 504 static Code* megamorphic_stub() { | 503 static Code* megamorphic_stub() { | 
| 505 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 504 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 
| 506 } | 505 } | 
| 506 static Code* megamorphic_stub_strict() { | |
| 507 return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict); | |
| 508 } | |
| 507 static Code* generic_stub() { | 509 static Code* generic_stub() { | 
| 508 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 510 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 
| 509 } | 511 } | 
| 512 static Code* generic_stub_strict() { | |
| 513 return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict); | |
| 514 } | |
| 510 | 515 | 
| 511 static void Clear(Address address, Code* target); | 516 static void Clear(Address address, Code* target); | 
| 512 | 517 | 
| 513 // Support for patching the map that is checked in an inlined | 518 // Support for patching the map that is checked in an inlined | 
| 514 // version of keyed store. | 519 // version of keyed store. | 
| 515 // The address is the patch point for the IC call | 520 // The address is the patch point for the IC call | 
| 516 // (Assembler::kCallTargetAddressOffset before the end of | 521 // (Assembler::kCallTargetAddressOffset before the end of | 
| 517 // the call/return address). | 522 // the call/return address). | 
| 518 // The map is the new map that the inlined code should check against. | 523 // The map is the new map that the inlined code should check against. | 
| 519 static bool PatchInlinedStore(Address address, Object* map); | 524 static bool PatchInlinedStore(Address address, Object* map); | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 | 614 | 
| 610 Token::Value op_; | 615 Token::Value op_; | 
| 611 }; | 616 }; | 
| 612 | 617 | 
| 613 // Helper for TRBinaryOpIC and CompareIC. | 618 // Helper for TRBinaryOpIC and CompareIC. | 
| 614 void PatchInlinedSmiCode(Address address); | 619 void PatchInlinedSmiCode(Address address); | 
| 615 | 620 | 
| 616 } } // namespace v8::internal | 621 } } // namespace v8::internal | 
| 617 | 622 | 
| 618 #endif // V8_IC_H_ | 623 #endif // V8_IC_H_ | 
| OLD | NEW |