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

Side by Side Diff: src/liveedit.cc

Issue 10915062: Add checks to runtime functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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/lithium-ia32.cc ('k') | src/messages.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 void SetSmiValueField(int field_position, int value) { 663 void SetSmiValueField(int field_position, int value) {
664 SetElementNonStrict(array_, 664 SetElementNonStrict(array_,
665 field_position, 665 field_position,
666 Handle<Smi>(Smi::FromInt(value))); 666 Handle<Smi>(Smi::FromInt(value)));
667 } 667 }
668 Object* GetField(int field_position) { 668 Object* GetField(int field_position) {
669 return array_->GetElementNoExceptionThrown(field_position); 669 return array_->GetElementNoExceptionThrown(field_position);
670 } 670 }
671 int GetSmiValueField(int field_position) { 671 int GetSmiValueField(int field_position) {
672 Object* res = GetField(field_position); 672 Object* res = GetField(field_position);
673 CHECK(res->IsSmi());
673 return Smi::cast(res)->value(); 674 return Smi::cast(res)->value();
674 } 675 }
675 676
676 private: 677 private:
677 Handle<JSArray> array_; 678 Handle<JSArray> array_;
678 }; 679 };
679 680
680 681
681 // Represents some function compilation details. This structure will be used 682 // Represents some function compilation details. This structure will be used
682 // from JavaScript. It contains Code object, which is kept wrapped 683 // from JavaScript. It contains Code object, which is kept wrapped
(...skipping 24 matching lines...) Expand all
707 this->SetField(kOuterScopeInfoOffset_, scope_info_array); 708 this->SetField(kOuterScopeInfoOffset_, scope_info_array);
708 } 709 }
709 void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info) { 710 void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info) {
710 Handle<JSValue> info_holder = WrapInJSValue(info); 711 Handle<JSValue> info_holder = WrapInJSValue(info);
711 this->SetField(kSharedFunctionInfoOffset_, info_holder); 712 this->SetField(kSharedFunctionInfoOffset_, info_holder);
712 } 713 }
713 int GetParentIndex() { 714 int GetParentIndex() {
714 return this->GetSmiValueField(kParentIndexOffset_); 715 return this->GetSmiValueField(kParentIndexOffset_);
715 } 716 }
716 Handle<Code> GetFunctionCode() { 717 Handle<Code> GetFunctionCode() {
717 Handle<Object> raw_result = UnwrapJSValue(Handle<JSValue>( 718 Object* element = this->GetField(kCodeOffset_);
718 JSValue::cast(this->GetField(kCodeOffset_)))); 719 CHECK(element->IsJSValue());
720 Handle<JSValue> value_wrapper(JSValue::cast(element));
721 Handle<Object> raw_result = UnwrapJSValue(value_wrapper);
722 CHECK(raw_result->IsCode());
719 return Handle<Code>::cast(raw_result); 723 return Handle<Code>::cast(raw_result);
720 } 724 }
721 Handle<Object> GetCodeScopeInfo() { 725 Handle<Object> GetCodeScopeInfo() {
722 Handle<Object> raw_result = UnwrapJSValue(Handle<JSValue>( 726 Object* element = this->GetField(kCodeScopeInfoOffset_);
723 JSValue::cast(this->GetField(kCodeScopeInfoOffset_)))); 727 CHECK(element->IsJSValue());
724 return raw_result; 728 return UnwrapJSValue(Handle<JSValue>(JSValue::cast(element)));
725 } 729 }
726 int GetStartPosition() { 730 int GetStartPosition() {
727 return this->GetSmiValueField(kStartPositionOffset_); 731 return this->GetSmiValueField(kStartPositionOffset_);
728 } 732 }
729 int GetEndPosition() { 733 int GetEndPosition() {
730 return this->GetSmiValueField(kEndPositionOffset_); 734 return this->GetSmiValueField(kEndPositionOffset_);
731 } 735 }
732 736
733 private: 737 private:
734 static const int kFunctionNameOffset_ = 0; 738 static const int kFunctionNameOffset_ = 0;
(...skipping 29 matching lines...) Expand all
764 Handle<SharedFunctionInfo> info) { 768 Handle<SharedFunctionInfo> info) {
765 HandleScope scope; 769 HandleScope scope;
766 this->SetField(kFunctionNameOffset_, name); 770 this->SetField(kFunctionNameOffset_, name);
767 Handle<JSValue> info_holder = WrapInJSValue(info); 771 Handle<JSValue> info_holder = WrapInJSValue(info);
768 this->SetField(kSharedInfoOffset_, info_holder); 772 this->SetField(kSharedInfoOffset_, info_holder);
769 this->SetSmiValueField(kStartPositionOffset_, start_position); 773 this->SetSmiValueField(kStartPositionOffset_, start_position);
770 this->SetSmiValueField(kEndPositionOffset_, end_position); 774 this->SetSmiValueField(kEndPositionOffset_, end_position);
771 } 775 }
772 Handle<SharedFunctionInfo> GetInfo() { 776 Handle<SharedFunctionInfo> GetInfo() {
773 Object* element = this->GetField(kSharedInfoOffset_); 777 Object* element = this->GetField(kSharedInfoOffset_);
778 CHECK(element->IsJSValue());
774 Handle<JSValue> value_wrapper(JSValue::cast(element)); 779 Handle<JSValue> value_wrapper(JSValue::cast(element));
775 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); 780 Handle<Object> raw_result = UnwrapJSValue(value_wrapper);
781 CHECK(raw_result->IsSharedFunctionInfo());
776 return Handle<SharedFunctionInfo>::cast(raw_result); 782 return Handle<SharedFunctionInfo>::cast(raw_result);
777 } 783 }
778 784
779 private: 785 private:
780 static const int kFunctionNameOffset_ = 0; 786 static const int kFunctionNameOffset_ = 0;
781 static const int kStartPositionOffset_ = 1; 787 static const int kStartPositionOffset_ = 1;
782 static const int kEndPositionOffset_ = 2; 788 static const int kEndPositionOffset_ = 2;
783 static const int kSharedInfoOffset_ = 3; 789 static const int kSharedInfoOffset_ = 3;
784 static const int kSize_ = 4; 790 static const int kSize_ = 4;
785 791
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 Isolate::Current()->compilation_cache()->Remove(shared_info); 1126 Isolate::Current()->compilation_cache()->Remove(shared_info);
1121 1127
1122 return HEAP->undefined_value(); 1128 return HEAP->undefined_value();
1123 } 1129 }
1124 1130
1125 1131
1126 void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper, 1132 void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper,
1127 Handle<Object> script_handle) { 1133 Handle<Object> script_handle) {
1128 Handle<SharedFunctionInfo> shared_info = 1134 Handle<SharedFunctionInfo> shared_info =
1129 Handle<SharedFunctionInfo>::cast(UnwrapJSValue(function_wrapper)); 1135 Handle<SharedFunctionInfo>::cast(UnwrapJSValue(function_wrapper));
1136 CHECK(script_handle->IsScript() || script_handle->IsUndefined());
1130 shared_info->set_script(*script_handle); 1137 shared_info->set_script(*script_handle);
1131 1138
1132 Isolate::Current()->compilation_cache()->Remove(shared_info); 1139 Isolate::Current()->compilation_cache()->Remove(shared_info);
1133 } 1140 }
1134 1141
1135 1142
1136 // For a script text change (defined as position_change_array), translates 1143 // For a script text change (defined as position_change_array), translates
1137 // position in unchanged text to position in changed text. 1144 // position in unchanged text to position in changed text.
1138 // Text change is a set of non-overlapping regions in text, that have changed 1145 // Text change is a set of non-overlapping regions in text, that have changed
1139 // their contents and length. It is specified as array of groups of 3 numbers: 1146 // their contents and length. It is specified as array of groups of 3 numbers:
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1905
1899 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 1906 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
1900 return false; 1907 return false;
1901 } 1908 }
1902 1909
1903 #endif // ENABLE_DEBUGGER_SUPPORT 1910 #endif // ENABLE_DEBUGGER_SUPPORT
1904 1911
1905 1912
1906 1913
1907 } } // namespace v8::internal 1914 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698