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

Side by Side Diff: src/liveedit.cc

Issue 3970005: Make Failure inherit from MaybeObject instead of Object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month 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/liveedit.h ('k') | src/log.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 protected: 458 protected:
459 void SetField(int field_position, Handle<Object> value) { 459 void SetField(int field_position, Handle<Object> value) {
460 SetElement(array_, field_position, value); 460 SetElement(array_, field_position, value);
461 } 461 }
462 void SetSmiValueField(int field_position, int value) { 462 void SetSmiValueField(int field_position, int value) {
463 SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value))); 463 SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value)));
464 } 464 }
465 Object* GetField(int field_position) { 465 Object* GetField(int field_position) {
466 return array_->GetElement(field_position); 466 return array_->GetElementNoExceptionThrown(field_position);
467 } 467 }
468 int GetSmiValueField(int field_position) { 468 int GetSmiValueField(int field_position) {
469 Object* res = GetField(field_position); 469 Object* res = GetField(field_position);
470 return Smi::cast(res)->value(); 470 return Smi::cast(res)->value();
471 } 471 }
472 472
473 private: 473 private:
474 Handle<JSArray> array_; 474 Handle<JSArray> array_;
475 }; 475 };
476 476
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 }; 543 };
544 544
545 545
546 // Wraps SharedFunctionInfo along with some of its fields for passing it 546 // Wraps SharedFunctionInfo along with some of its fields for passing it
547 // back to JavaScript. SharedFunctionInfo object itself is additionally 547 // back to JavaScript. SharedFunctionInfo object itself is additionally
548 // wrapped into BlindReference for sanitizing reasons. 548 // wrapped into BlindReference for sanitizing reasons.
549 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> { 549 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
550 public: 550 public:
551 static bool IsInstance(Handle<JSArray> array) { 551 static bool IsInstance(Handle<JSArray> array) {
552 return array->length() == Smi::FromInt(kSize_) && 552 return array->length() == Smi::FromInt(kSize_) &&
553 array->GetElement(kSharedInfoOffset_)->IsJSValue(); 553 array->GetElementNoExceptionThrown(kSharedInfoOffset_)->IsJSValue();
554 } 554 }
555 555
556 explicit SharedInfoWrapper(Handle<JSArray> array) 556 explicit SharedInfoWrapper(Handle<JSArray> array)
557 : JSArrayBasedStruct<SharedInfoWrapper>(array) { 557 : JSArrayBasedStruct<SharedInfoWrapper>(array) {
558 } 558 }
559 559
560 void SetProperties(Handle<String> name, int start_position, int end_position, 560 void SetProperties(Handle<String> name, int start_position, int end_position,
561 Handle<SharedFunctionInfo> info) { 561 Handle<SharedFunctionInfo> info) {
562 HandleScope scope; 562 HandleScope scope;
563 this->SetField(kFunctionNameOffset_, name); 563 this->SetField(kFunctionNameOffset_, name);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 info.SetInitialProperties(fun->name(), fun->start_position(), 598 info.SetInitialProperties(fun->name(), fun->start_position(),
599 fun->end_position(), fun->num_parameters(), 599 fun->end_position(), fun->num_parameters(),
600 current_parent_index_); 600 current_parent_index_);
601 current_parent_index_ = len_; 601 current_parent_index_ = len_;
602 SetElement(result_, len_, info.GetJSArray()); 602 SetElement(result_, len_, info.GetJSArray());
603 len_++; 603 len_++;
604 } 604 }
605 605
606 void FunctionDone() { 606 void FunctionDone() {
607 HandleScope scope; 607 HandleScope scope;
608 FunctionInfoWrapper info = 608 Object* element =
609 FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_)); 609 result_->GetElementNoExceptionThrown(current_parent_index_);
610 FunctionInfoWrapper info = FunctionInfoWrapper::cast(element);
610 current_parent_index_ = info.GetParentIndex(); 611 current_parent_index_ = info.GetParentIndex();
611 } 612 }
612 613
613 // Saves only function code, because for a script function we 614 // Saves only function code, because for a script function we
614 // may never create a SharedFunctionInfo object. 615 // may never create a SharedFunctionInfo object.
615 void FunctionCode(Handle<Code> function_code) { 616 void FunctionCode(Handle<Code> function_code) {
616 FunctionInfoWrapper info = 617 Object* element =
617 FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_)); 618 result_->GetElementNoExceptionThrown(current_parent_index_);
619 FunctionInfoWrapper info = FunctionInfoWrapper::cast(element);
618 info.SetFunctionCode(function_code, Handle<Object>(Heap::null_value())); 620 info.SetFunctionCode(function_code, Handle<Object>(Heap::null_value()));
619 } 621 }
620 622
621 // Saves full information about a function: its code, its scope info 623 // Saves full information about a function: its code, its scope info
622 // and a SharedFunctionInfo object. 624 // and a SharedFunctionInfo object.
623 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope) { 625 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope) {
624 if (!shared->IsSharedFunctionInfo()) { 626 if (!shared->IsSharedFunctionInfo()) {
625 return; 627 return;
626 } 628 }
627 FunctionInfoWrapper info = 629 Object* element =
628 FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_)); 630 result_->GetElementNoExceptionThrown(current_parent_index_);
631 FunctionInfoWrapper info = FunctionInfoWrapper::cast(element);
629 info.SetFunctionCode(Handle<Code>(shared->code()), 632 info.SetFunctionCode(Handle<Code>(shared->code()),
630 Handle<Object>(shared->scope_info())); 633 Handle<Object>(shared->scope_info()));
631 info.SetSharedFunctionInfo(shared); 634 info.SetSharedFunctionInfo(shared);
632 635
633 Handle<Object> scope_info_list(SerializeFunctionScope(scope)); 636 Handle<Object> scope_info_list(SerializeFunctionScope(scope));
634 info.SetOuterScopeInfo(scope_info_list); 637 info.SetOuterScopeInfo(scope_info_list);
635 } 638 }
636 639
637 Handle<JSArray> GetResult() { return result_; } 640 Handle<JSArray> GetResult() { return result_; }
638 641
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 717
715 return *(listener.GetResult()); 718 return *(listener.GetResult());
716 } 719 }
717 720
718 721
719 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { 722 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
720 HandleScope scope; 723 HandleScope scope;
721 int len = Smi::cast(array->length())->value(); 724 int len = Smi::cast(array->length())->value();
722 for (int i = 0; i < len; i++) { 725 for (int i = 0; i < len; i++) {
723 Handle<SharedFunctionInfo> info( 726 Handle<SharedFunctionInfo> info(
724 SharedFunctionInfo::cast(array->GetElement(i))); 727 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i)));
725 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); 728 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create();
726 Handle<String> name_handle(String::cast(info->name())); 729 Handle<String> name_handle(String::cast(info->name()));
727 info_wrapper.SetProperties(name_handle, info->start_position(), 730 info_wrapper.SetProperties(name_handle, info->start_position(),
728 info->end_position(), info); 731 info->end_position(), info);
729 SetElement(array, i, info_wrapper.GetJSArray()); 732 SetElement(array, i, info_wrapper.GetJSArray());
730 } 733 }
731 } 734 }
732 735
733 736
734 // Visitor that collects all references to a particular code object, 737 // Visitor that collects all references to a particular code object,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 } 821 }
819 822
820 823
821 // Check whether the code is natural function code (not a lazy-compile stub 824 // Check whether the code is natural function code (not a lazy-compile stub
822 // code). 825 // code).
823 static bool IsJSFunctionCode(Code* code) { 826 static bool IsJSFunctionCode(Code* code) {
824 return code->kind() == Code::FUNCTION; 827 return code->kind() == Code::FUNCTION;
825 } 828 }
826 829
827 830
828 Object* LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array, 831 MaybeObject* LiveEdit::ReplaceFunctionCode(
829 Handle<JSArray> shared_info_array) { 832 Handle<JSArray> new_compile_info_array,
833 Handle<JSArray> shared_info_array) {
830 HandleScope scope; 834 HandleScope scope;
831 835
832 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { 836 if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
833 return Top::ThrowIllegalOperation(); 837 return Top::ThrowIllegalOperation();
834 } 838 }
835 839
836 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); 840 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
837 SharedInfoWrapper shared_info_wrapper(shared_info_array); 841 SharedInfoWrapper shared_info_wrapper(shared_info_array);
838 842
839 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 843 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // Each group describes a change in text; groups are sorted by change_begin. 886 // Each group describes a change in text; groups are sorted by change_begin.
883 // Only position in text beyond any changes may be successfully translated. 887 // Only position in text beyond any changes may be successfully translated.
884 // If a positions is inside some region that changed, result is currently 888 // If a positions is inside some region that changed, result is currently
885 // undefined. 889 // undefined.
886 static int TranslatePosition(int original_position, 890 static int TranslatePosition(int original_position,
887 Handle<JSArray> position_change_array) { 891 Handle<JSArray> position_change_array) {
888 int position_diff = 0; 892 int position_diff = 0;
889 int array_len = Smi::cast(position_change_array->length())->value(); 893 int array_len = Smi::cast(position_change_array->length())->value();
890 // TODO(635): binary search may be used here 894 // TODO(635): binary search may be used here
891 for (int i = 0; i < array_len; i += 3) { 895 for (int i = 0; i < array_len; i += 3) {
892 int chunk_start = 896 Object* element = position_change_array->GetElementNoExceptionThrown(i);
893 Smi::cast(position_change_array->GetElement(i))->value(); 897 int chunk_start = Smi::cast(element)->value();
894 if (original_position < chunk_start) { 898 if (original_position < chunk_start) {
895 break; 899 break;
896 } 900 }
897 int chunk_end = 901 element = position_change_array->GetElementNoExceptionThrown(i + 1);
898 Smi::cast(position_change_array->GetElement(i + 1))->value(); 902 int chunk_end = Smi::cast(element)->value();
899 // Position mustn't be inside a chunk. 903 // Position mustn't be inside a chunk.
900 ASSERT(original_position >= chunk_end); 904 ASSERT(original_position >= chunk_end);
901 int chunk_changed_end = 905 element = position_change_array->GetElementNoExceptionThrown(i + 2);
902 Smi::cast(position_change_array->GetElement(i + 2))->value(); 906 int chunk_changed_end = Smi::cast(element)->value();
903 position_diff = chunk_changed_end - chunk_end; 907 position_diff = chunk_changed_end - chunk_end;
904 } 908 }
905 909
906 return original_position + position_diff; 910 return original_position + position_diff;
907 } 911 }
908 912
909 913
910 // Auto-growing buffer for writing relocation info code section. This buffer 914 // Auto-growing buffer for writing relocation info code section. This buffer
911 // is a simplified version of buffer from Assembler. Unlike Assembler, this 915 // is a simplified version of buffer from Assembler. Unlike Assembler, this
912 // class is platform-independent and it works without dealing with instructions. 916 // class is platform-independent and it works without dealing with instructions.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } else { 1021 } else {
1018 // Relocation info section now has different size. We cannot simply 1022 // Relocation info section now has different size. We cannot simply
1019 // rewrite it inside code object. Instead we have to create a new 1023 // rewrite it inside code object. Instead we have to create a new
1020 // code object. 1024 // code object.
1021 Handle<Code> result(Factory::CopyCode(code, buffer)); 1025 Handle<Code> result(Factory::CopyCode(code, buffer));
1022 return result; 1026 return result;
1023 } 1027 }
1024 } 1028 }
1025 1029
1026 1030
1027 Object* LiveEdit::PatchFunctionPositions( 1031 MaybeObject* LiveEdit::PatchFunctionPositions(
1028 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { 1032 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) {
1029 1033
1030 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { 1034 if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
1031 return Top::ThrowIllegalOperation(); 1035 return Top::ThrowIllegalOperation();
1032 } 1036 }
1033 1037
1034 SharedInfoWrapper shared_info_wrapper(shared_info_array); 1038 SharedInfoWrapper shared_info_wrapper(shared_info_array);
1035 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); 1039 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo();
1036 1040
1037 int old_function_start = info->start_position(); 1041 int old_function_start = info->start_position();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 // Check an activation against list of functions. If there is a function 1135 // Check an activation against list of functions. If there is a function
1132 // that matches, its status in result array is changed to status argument value. 1136 // that matches, its status in result array is changed to status argument value.
1133 static bool CheckActivation(Handle<JSArray> shared_info_array, 1137 static bool CheckActivation(Handle<JSArray> shared_info_array,
1134 Handle<JSArray> result, StackFrame* frame, 1138 Handle<JSArray> result, StackFrame* frame,
1135 LiveEdit::FunctionPatchabilityStatus status) { 1139 LiveEdit::FunctionPatchabilityStatus status) {
1136 if (!frame->is_java_script()) { 1140 if (!frame->is_java_script()) {
1137 return false; 1141 return false;
1138 } 1142 }
1139 int len = Smi::cast(shared_info_array->length())->value(); 1143 int len = Smi::cast(shared_info_array->length())->value();
1140 for (int i = 0; i < len; i++) { 1144 for (int i = 0; i < len; i++) {
1141 JSValue* wrapper = JSValue::cast(shared_info_array->GetElement(i)); 1145 JSValue* wrapper =
1146 JSValue::cast(shared_info_array->GetElementNoExceptionThrown(i));
1142 Handle<SharedFunctionInfo> shared( 1147 Handle<SharedFunctionInfo> shared(
1143 SharedFunctionInfo::cast(wrapper->value())); 1148 SharedFunctionInfo::cast(wrapper->value()));
1144 1149
1145 if (frame->code() == shared->code()) { 1150 if (frame->code() == shared->code()) {
1146 SetElement(result, i, Handle<Smi>(Smi::FromInt(status))); 1151 SetElement(result, i, Handle<Smi>(Smi::FromInt(status)));
1147 return true; 1152 return true;
1148 } 1153 }
1149 } 1154 }
1150 return false; 1155 return false;
1151 } 1156 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 1474
1470 bool LiveEditFunctionTracker::IsActive() { 1475 bool LiveEditFunctionTracker::IsActive() {
1471 return false; 1476 return false;
1472 } 1477 }
1473 1478
1474 #endif // ENABLE_DEBUGGER_SUPPORT 1479 #endif // ENABLE_DEBUGGER_SUPPORT
1475 1480
1476 1481
1477 1482
1478 } } // namespace v8::internal 1483 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/liveedit.h ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698