Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: src/ic.h

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
Patch Set: Assign to read only property in strict mode. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/virtual-frame-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 StrictModeFlag strict_mode,
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 StrictModeFlag strict_mode);
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
433 // lookup result. 427 // lookup result.
434 void UpdateCaches(LookupResult* lookup, 428 void UpdateCaches(LookupResult* lookup,
435 State state, 429 State state,
436 Code::ExtraICState extra_ic_state, 430 StrictModeFlag strict_mode,
437 Handle<JSObject> receiver, 431 Handle<JSObject> receiver,
438 Handle<String> name, 432 Handle<String> name,
439 Handle<Object> value); 433 Handle<Object> value);
440 434
435 void set_target(Code* code) {
436 ASSERT(code->extra_ic_state() == target()->extra_ic_state());
437 IC::set_target(code);
438 }
439
441 // Stub accessors. 440 // Stub accessors.
442 static Code* megamorphic_stub() { 441 static Code* megamorphic_stub() {
443 return Builtins::builtin(Builtins::StoreIC_Megamorphic); 442 return Builtins::builtin(Builtins::StoreIC_Megamorphic);
444 } 443 }
445 static Code* megamorphic_stub_strict() { 444 static Code* megamorphic_stub_strict() {
446 return Builtins::builtin(Builtins::StoreIC_Megamorphic_Strict); 445 return Builtins::builtin(Builtins::StoreIC_Megamorphic_Strict);
447 } 446 }
448 static Code* initialize_stub() { 447 static Code* initialize_stub() {
449 return Builtins::builtin(Builtins::StoreIC_Initialize); 448 return Builtins::builtin(Builtins::StoreIC_Initialize);
450 } 449 }
(...skipping 15 matching lines...) Expand all
466 465
467 friend class IC; 466 friend class IC;
468 }; 467 };
469 468
470 469
471 class KeyedStoreIC: public IC { 470 class KeyedStoreIC: public IC {
472 public: 471 public:
473 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } 472 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { }
474 473
475 MUST_USE_RESULT MaybeObject* Store(State state, 474 MUST_USE_RESULT MaybeObject* Store(State state,
475 StrictModeFlag strict_mode,
476 Handle<Object> object, 476 Handle<Object> object,
477 Handle<Object> name, 477 Handle<Object> name,
478 Handle<Object> value); 478 Handle<Object> value);
479 479
480 // Code generators for stub routines. Only called once at startup. 480 // Code generators for stub routines. Only called once at startup.
481 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 481 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
482 static void GenerateMiss(MacroAssembler* masm); 482 static void GenerateMiss(MacroAssembler* masm);
483 static void GenerateRuntimeSetProperty(MacroAssembler* masm); 483 static void GenerateRuntimeSetProperty(MacroAssembler* masm,
484 static void GenerateGeneric(MacroAssembler* masm); 484 StrictModeFlag strict_mode);
485 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode);
485 486
486 // Clear the inlined version so the IC is always hit. 487 // Clear the inlined version so the IC is always hit.
487 static void ClearInlinedVersion(Address address); 488 static void ClearInlinedVersion(Address address);
488 489
489 // Restore the inlined version so the fast case can get hit. 490 // Restore the inlined version so the fast case can get hit.
490 static void RestoreInlinedVersion(Address address); 491 static void RestoreInlinedVersion(Address address);
491 492
492 private: 493 private:
493 // Update the inline cache. 494 // Update the inline cache.
494 void UpdateCaches(LookupResult* lookup, 495 void UpdateCaches(LookupResult* lookup,
495 State state, 496 State state,
497 StrictModeFlag strict_mode,
496 Handle<JSObject> receiver, 498 Handle<JSObject> receiver,
497 Handle<String> name, 499 Handle<String> name,
498 Handle<Object> value); 500 Handle<Object> value);
499 501
502 void set_target(Code* code) {
503 ASSERT(code->extra_ic_state() == target()->extra_ic_state());
504 IC::set_target(code);
505 }
506
500 // Stub accessors. 507 // Stub accessors.
501 static Code* initialize_stub() { 508 static Code* initialize_stub() {
502 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); 509 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize);
503 } 510 }
511 static Code* initialize_stub_strict() {
512 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize_Strict);
513 }
504 static Code* megamorphic_stub() { 514 static Code* megamorphic_stub() {
505 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); 515 return Builtins::builtin(Builtins::KeyedStoreIC_Generic);
506 } 516 }
517 static Code* megamorphic_stub_strict() {
518 return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict);
519 }
507 static Code* generic_stub() { 520 static Code* generic_stub() {
508 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); 521 return Builtins::builtin(Builtins::KeyedStoreIC_Generic);
509 } 522 }
523 static Code* generic_stub_strict() {
524 return Builtins::builtin(Builtins::KeyedStoreIC_Generic_Strict);
525 }
510 526
511 static void Clear(Address address, Code* target); 527 static void Clear(Address address, Code* target);
512 528
513 // Support for patching the map that is checked in an inlined 529 // Support for patching the map that is checked in an inlined
514 // version of keyed store. 530 // version of keyed store.
515 // The address is the patch point for the IC call 531 // The address is the patch point for the IC call
516 // (Assembler::kCallTargetAddressOffset before the end of 532 // (Assembler::kCallTargetAddressOffset before the end of
517 // the call/return address). 533 // the call/return address).
518 // The map is the new map that the inlined code should check against. 534 // The map is the new map that the inlined code should check against.
519 static bool PatchInlinedStore(Address address, Object* map); 535 static bool PatchInlinedStore(Address address, Object* map);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 625
610 Token::Value op_; 626 Token::Value op_;
611 }; 627 };
612 628
613 // Helper for TRBinaryOpIC and CompareIC. 629 // Helper for TRBinaryOpIC and CompareIC.
614 void PatchInlinedSmiCode(Address address); 630 void PatchInlinedSmiCode(Address address);
615 631
616 } } // namespace v8::internal 632 } } // namespace v8::internal
617 633
618 #endif // V8_IC_H_ 634 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « src/ia32/virtual-frame-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698