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

Side by Side Diff: src/debug/liveedit.cc

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/debug/liveedit.h ('k') | src/i18n.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/liveedit.h" 5 #include "src/debug/liveedit.h"
6 6
7 #include "src/ast/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 fun->end_position(), fun->parameter_count(), 703 fun->end_position(), fun->parameter_count(),
704 fun->materialized_literal_count(), 704 fun->materialized_literal_count(),
705 current_parent_index_); 705 current_parent_index_);
706 current_parent_index_ = len_; 706 current_parent_index_ = len_;
707 SetElementSloppy(result_, len_, info.GetJSArray()); 707 SetElementSloppy(result_, len_, info.GetJSArray());
708 len_++; 708 len_++;
709 } 709 }
710 710
711 void FunctionDone() { 711 void FunctionDone() {
712 HandleScope scope(isolate()); 712 HandleScope scope(isolate());
713 FunctionInfoWrapper info = 713 FunctionInfoWrapper info = FunctionInfoWrapper::cast(
714 FunctionInfoWrapper::cast( 714 *JSReceiver::GetElement(isolate(), result_, current_parent_index_)
715 *Object::GetElement( 715 .ToHandleChecked());
716 isolate(), result_, current_parent_index_).ToHandleChecked());
717 current_parent_index_ = info.GetParentIndex(); 716 current_parent_index_ = info.GetParentIndex();
718 } 717 }
719 718
720 // Saves only function code, because for a script function we 719 // Saves only function code, because for a script function we
721 // may never create a SharedFunctionInfo object. 720 // may never create a SharedFunctionInfo object.
722 void FunctionCode(Handle<Code> function_code) { 721 void FunctionCode(Handle<Code> function_code) {
723 FunctionInfoWrapper info = 722 FunctionInfoWrapper info = FunctionInfoWrapper::cast(
724 FunctionInfoWrapper::cast( 723 *JSReceiver::GetElement(isolate(), result_, current_parent_index_)
725 *Object::GetElement( 724 .ToHandleChecked());
726 isolate(), result_, current_parent_index_).ToHandleChecked());
727 info.SetFunctionCode(function_code, 725 info.SetFunctionCode(function_code,
728 Handle<HeapObject>(isolate()->heap()->null_value())); 726 Handle<HeapObject>(isolate()->heap()->null_value()));
729 } 727 }
730 728
731 // Saves full information about a function: its code, its scope info 729 // Saves full information about a function: its code, its scope info
732 // and a SharedFunctionInfo object. 730 // and a SharedFunctionInfo object.
733 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope, 731 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope,
734 Zone* zone) { 732 Zone* zone) {
735 if (!shared->IsSharedFunctionInfo()) { 733 if (!shared->IsSharedFunctionInfo()) {
736 return; 734 return;
737 } 735 }
738 FunctionInfoWrapper info = 736 FunctionInfoWrapper info = FunctionInfoWrapper::cast(
739 FunctionInfoWrapper::cast( 737 *JSReceiver::GetElement(isolate(), result_, current_parent_index_)
740 *Object::GetElement( 738 .ToHandleChecked());
741 isolate(), result_, current_parent_index_).ToHandleChecked());
742 info.SetFunctionCode(Handle<Code>(shared->code()), 739 info.SetFunctionCode(Handle<Code>(shared->code()),
743 Handle<HeapObject>(shared->scope_info())); 740 Handle<HeapObject>(shared->scope_info()));
744 info.SetSharedFunctionInfo(shared); 741 info.SetSharedFunctionInfo(shared);
745 742
746 Handle<Object> scope_info_list = SerializeFunctionScope(scope, zone); 743 Handle<Object> scope_info_list = SerializeFunctionScope(scope, zone);
747 info.SetFunctionScopeInfo(scope_info_list); 744 info.SetFunctionScopeInfo(scope_info_list);
748 } 745 }
749 746
750 Handle<JSArray> GetResult() { return result_; } 747 Handle<JSArray> GetResult() { return result_; }
751 748
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 // If a positions is inside some region that changed, result is currently 1175 // If a positions is inside some region that changed, result is currently
1179 // undefined. 1176 // undefined.
1180 static int TranslatePosition(int original_position, 1177 static int TranslatePosition(int original_position,
1181 Handle<JSArray> position_change_array) { 1178 Handle<JSArray> position_change_array) {
1182 int position_diff = 0; 1179 int position_diff = 0;
1183 int array_len = GetArrayLength(position_change_array); 1180 int array_len = GetArrayLength(position_change_array);
1184 Isolate* isolate = position_change_array->GetIsolate(); 1181 Isolate* isolate = position_change_array->GetIsolate();
1185 // TODO(635): binary search may be used here 1182 // TODO(635): binary search may be used here
1186 for (int i = 0; i < array_len; i += 3) { 1183 for (int i = 0; i < array_len; i += 3) {
1187 HandleScope scope(isolate); 1184 HandleScope scope(isolate);
1188 Handle<Object> element = Object::GetElement( 1185 Handle<Object> element =
1189 isolate, position_change_array, i).ToHandleChecked(); 1186 JSReceiver::GetElement(isolate, position_change_array, i)
1187 .ToHandleChecked();
1190 CHECK(element->IsSmi()); 1188 CHECK(element->IsSmi());
1191 int chunk_start = Handle<Smi>::cast(element)->value(); 1189 int chunk_start = Handle<Smi>::cast(element)->value();
1192 if (original_position < chunk_start) { 1190 if (original_position < chunk_start) {
1193 break; 1191 break;
1194 } 1192 }
1195 element = Object::GetElement( 1193 element = JSReceiver::GetElement(isolate, position_change_array, i + 1)
1196 isolate, position_change_array, i + 1).ToHandleChecked(); 1194 .ToHandleChecked();
1197 CHECK(element->IsSmi()); 1195 CHECK(element->IsSmi());
1198 int chunk_end = Handle<Smi>::cast(element)->value(); 1196 int chunk_end = Handle<Smi>::cast(element)->value();
1199 // Position mustn't be inside a chunk. 1197 // Position mustn't be inside a chunk.
1200 DCHECK(original_position >= chunk_end); 1198 DCHECK(original_position >= chunk_end);
1201 element = Object::GetElement( 1199 element = JSReceiver::GetElement(isolate, position_change_array, i + 2)
1202 isolate, position_change_array, i + 2).ToHandleChecked(); 1200 .ToHandleChecked();
1203 CHECK(element->IsSmi()); 1201 CHECK(element->IsSmi());
1204 int chunk_changed_end = Handle<Smi>::cast(element)->value(); 1202 int chunk_changed_end = Handle<Smi>::cast(element)->value();
1205 position_diff = chunk_changed_end - chunk_end; 1203 position_diff = chunk_changed_end - chunk_end;
1206 } 1204 }
1207 1205
1208 return original_position + position_diff; 1206 return original_position + position_diff;
1209 } 1207 }
1210 1208
1211 1209
1212 // Auto-growing buffer for writing relocation info code section. This buffer 1210 // Auto-growing buffer for writing relocation info code section. This buffer
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 LiveEdit::FunctionPatchabilityStatus status) { 1439 LiveEdit::FunctionPatchabilityStatus status) {
1442 if (!frame->is_java_script()) return false; 1440 if (!frame->is_java_script()) return false;
1443 1441
1444 Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function()); 1442 Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function());
1445 1443
1446 Isolate* isolate = shared_info_array->GetIsolate(); 1444 Isolate* isolate = shared_info_array->GetIsolate();
1447 int len = GetArrayLength(shared_info_array); 1445 int len = GetArrayLength(shared_info_array);
1448 for (int i = 0; i < len; i++) { 1446 for (int i = 0; i < len; i++) {
1449 HandleScope scope(isolate); 1447 HandleScope scope(isolate);
1450 Handle<Object> element = 1448 Handle<Object> element =
1451 Object::GetElement(isolate, shared_info_array, i).ToHandleChecked(); 1449 JSReceiver::GetElement(isolate, shared_info_array, i).ToHandleChecked();
1452 Handle<JSValue> jsvalue = Handle<JSValue>::cast(element); 1450 Handle<JSValue> jsvalue = Handle<JSValue>::cast(element);
1453 Handle<SharedFunctionInfo> shared = 1451 Handle<SharedFunctionInfo> shared =
1454 UnwrapSharedFunctionInfoFromJSValue(jsvalue); 1452 UnwrapSharedFunctionInfoFromJSValue(jsvalue);
1455 1453
1456 if (function->Inlines(*shared)) { 1454 if (function->Inlines(*shared)) {
1457 SetElementSloppy(result, i, Handle<Smi>(Smi::FromInt(status), isolate)); 1455 SetElementSloppy(result, i, Handle<Smi>(Smi::FromInt(status), isolate));
1458 return true; 1456 return true;
1459 } 1457 }
1460 } 1458 }
1461 return false; 1459 return false;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 if (!frame->is_java_script()) return false; 1652 if (!frame->is_java_script()) return false;
1655 JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame); 1653 JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame);
1656 Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared()); 1654 Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared());
1657 Isolate* isolate = old_shared->GetIsolate(); 1655 Isolate* isolate = old_shared->GetIsolate();
1658 int len = GetArrayLength(old_shared_array_); 1656 int len = GetArrayLength(old_shared_array_);
1659 // Find corresponding new shared function info and return whether it 1657 // Find corresponding new shared function info and return whether it
1660 // references new.target. 1658 // references new.target.
1661 for (int i = 0; i < len; i++) { 1659 for (int i = 0; i < len; i++) {
1662 HandleScope scope(isolate); 1660 HandleScope scope(isolate);
1663 Handle<Object> old_element = 1661 Handle<Object> old_element =
1664 Object::GetElement(isolate, old_shared_array_, i).ToHandleChecked(); 1662 JSReceiver::GetElement(isolate, old_shared_array_, i)
1663 .ToHandleChecked();
1665 if (!old_shared.is_identical_to(UnwrapSharedFunctionInfoFromJSValue( 1664 if (!old_shared.is_identical_to(UnwrapSharedFunctionInfoFromJSValue(
1666 Handle<JSValue>::cast(old_element)))) { 1665 Handle<JSValue>::cast(old_element)))) {
1667 continue; 1666 continue;
1668 } 1667 }
1669 1668
1670 Handle<Object> new_element = 1669 Handle<Object> new_element =
1671 Object::GetElement(isolate, new_shared_array_, i).ToHandleChecked(); 1670 JSReceiver::GetElement(isolate, new_shared_array_, i)
1671 .ToHandleChecked();
1672 if (new_element->IsUndefined()) return false; 1672 if (new_element->IsUndefined()) return false;
1673 Handle<SharedFunctionInfo> new_shared = 1673 Handle<SharedFunctionInfo> new_shared =
1674 UnwrapSharedFunctionInfoFromJSValue( 1674 UnwrapSharedFunctionInfoFromJSValue(
1675 Handle<JSValue>::cast(new_element)); 1675 Handle<JSValue>::cast(new_element));
1676 if (new_shared->scope_info()->HasNewTarget()) { 1676 if (new_shared->scope_info()->HasNewTarget()) {
1677 SetElementSloppy( 1677 SetElementSloppy(
1678 result_, i, 1678 result_, i,
1679 Handle<Smi>( 1679 Handle<Smi>(
1680 Smi::FromInt( 1680 Smi::FromInt(
1681 LiveEdit::FUNCTION_BLOCKED_NO_NEW_TARGET_ON_RESTART), 1681 LiveEdit::FUNCTION_BLOCKED_NO_NEW_TARGET_ON_RESTART),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 DropActivationsInActiveThreadImpl(isolate, target, do_drop); 1814 DropActivationsInActiveThreadImpl(isolate, target, do_drop);
1815 if (message) { 1815 if (message) {
1816 return message; 1816 return message;
1817 } 1817 }
1818 1818
1819 int array_len = GetArrayLength(old_shared_array); 1819 int array_len = GetArrayLength(old_shared_array);
1820 1820
1821 // Replace "blocked on active" with "replaced on active" status. 1821 // Replace "blocked on active" with "replaced on active" status.
1822 for (int i = 0; i < array_len; i++) { 1822 for (int i = 0; i < array_len; i++) {
1823 Handle<Object> obj = 1823 Handle<Object> obj =
1824 Object::GetElement(isolate, result, i).ToHandleChecked(); 1824 JSReceiver::GetElement(isolate, result, i).ToHandleChecked();
1825 if (*obj == Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { 1825 if (*obj == Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
1826 Handle<Object> replaced( 1826 Handle<Object> replaced(
1827 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate); 1827 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate);
1828 SetElementSloppy(result, i, replaced); 1828 SetElementSloppy(result, i, replaced);
1829 } 1829 }
1830 } 1830 }
1831 return NULL; 1831 return NULL;
1832 } 1832 }
1833 1833
1834 1834
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 isolate_->active_function_info_listener()->FunctionCode(code); 2035 isolate_->active_function_info_listener()->FunctionCode(code);
2036 } 2036 }
2037 2037
2038 2038
2039 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2039 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2040 return isolate->active_function_info_listener() != NULL; 2040 return isolate->active_function_info_listener() != NULL;
2041 } 2041 }
2042 2042
2043 } // namespace internal 2043 } // namespace internal
2044 } // namespace v8 2044 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/liveedit.h ('k') | src/i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698