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

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

Issue 1785403002: [runtime] split up loops with HandleScopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: making windose happy 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
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 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 // Each group describes a change in text; groups are sorted by change_begin. 1173 // Each group describes a change in text; groups are sorted by change_begin.
1174 // Only position in text beyond any changes may be successfully translated. 1174 // Only position in text beyond any changes may be successfully translated.
1175 // 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
1176 // undefined. 1176 // undefined.
1177 static int TranslatePosition(int original_position, 1177 static int TranslatePosition(int original_position,
1178 Handle<JSArray> position_change_array) { 1178 Handle<JSArray> position_change_array) {
1179 int position_diff = 0; 1179 int position_diff = 0;
1180 int array_len = GetArrayLength(position_change_array); 1180 int array_len = GetArrayLength(position_change_array);
1181 Isolate* isolate = position_change_array->GetIsolate(); 1181 Isolate* isolate = position_change_array->GetIsolate();
1182 // TODO(635): binary search may be used here 1182 // TODO(635): binary search may be used here
1183 for (int i = 0; i < array_len; i += 3) { 1183 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < array_len, i += 3, {
1184 HandleScope scope(isolate);
1185 Handle<Object> element = 1184 Handle<Object> element =
1186 JSReceiver::GetElement(isolate, position_change_array, i) 1185 JSReceiver::GetElement(isolate, position_change_array, i)
1187 .ToHandleChecked(); 1186 .ToHandleChecked();
1188 CHECK(element->IsSmi()); 1187 CHECK(element->IsSmi());
1189 int chunk_start = Handle<Smi>::cast(element)->value(); 1188 int chunk_start = Handle<Smi>::cast(element)->value();
1190 if (original_position < chunk_start) { 1189 if (original_position < chunk_start) {
1191 break; 1190 return original_position + position_diff;
1192 } 1191 }
1193 element = JSReceiver::GetElement(isolate, position_change_array, i + 1) 1192 element = JSReceiver::GetElement(isolate, position_change_array, i + 1)
1194 .ToHandleChecked(); 1193 .ToHandleChecked();
1195 CHECK(element->IsSmi()); 1194 CHECK(element->IsSmi());
1196 int chunk_end = Handle<Smi>::cast(element)->value(); 1195 int chunk_end = Handle<Smi>::cast(element)->value();
1197 // Position mustn't be inside a chunk. 1196 // Position mustn't be inside a chunk.
1198 DCHECK(original_position >= chunk_end); 1197 DCHECK(original_position >= chunk_end);
1199 element = JSReceiver::GetElement(isolate, position_change_array, i + 2) 1198 element = JSReceiver::GetElement(isolate, position_change_array, i + 2)
1200 .ToHandleChecked(); 1199 .ToHandleChecked();
1201 CHECK(element->IsSmi()); 1200 CHECK(element->IsSmi());
1202 int chunk_changed_end = Handle<Smi>::cast(element)->value(); 1201 int chunk_changed_end = Handle<Smi>::cast(element)->value();
1203 position_diff = chunk_changed_end - chunk_end; 1202 position_diff = chunk_changed_end - chunk_end;
1204 } 1203 });
1205 1204
1206 return original_position + position_diff; 1205 return original_position + position_diff;
1207 } 1206 }
1208 1207
1209 1208
1210 // Auto-growing buffer for writing relocation info code section. This buffer 1209 // Auto-growing buffer for writing relocation info code section. This buffer
1211 // is a simplified version of buffer from Assembler. Unlike Assembler, this 1210 // is a simplified version of buffer from Assembler. Unlike Assembler, this
1212 // class is platform-independent and it works without dealing with instructions. 1211 // class is platform-independent and it works without dealing with instructions.
1213 // As specified by RelocInfo format, the buffer is filled in reversed order: 1212 // As specified by RelocInfo format, the buffer is filled in reversed order:
1214 // from upper to lower addresses. 1213 // from upper to lower addresses.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 static bool CheckActivation(Handle<JSArray> shared_info_array, 1435 static bool CheckActivation(Handle<JSArray> shared_info_array,
1437 Handle<JSArray> result, 1436 Handle<JSArray> result,
1438 StackFrame* frame, 1437 StackFrame* frame,
1439 LiveEdit::FunctionPatchabilityStatus status) { 1438 LiveEdit::FunctionPatchabilityStatus status) {
1440 if (!frame->is_java_script()) return false; 1439 if (!frame->is_java_script()) return false;
1441 1440
1442 Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function()); 1441 Handle<JSFunction> function(JavaScriptFrame::cast(frame)->function());
1443 1442
1444 Isolate* isolate = shared_info_array->GetIsolate(); 1443 Isolate* isolate = shared_info_array->GetIsolate();
1445 int len = GetArrayLength(shared_info_array); 1444 int len = GetArrayLength(shared_info_array);
1446 for (int i = 0; i < len; i++) { 1445 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < len, i++, {
1447 HandleScope scope(isolate);
1448 Handle<Object> element = 1446 Handle<Object> element =
1449 JSReceiver::GetElement(isolate, shared_info_array, i).ToHandleChecked(); 1447 JSReceiver::GetElement(isolate, shared_info_array, i).ToHandleChecked();
1450 Handle<JSValue> jsvalue = Handle<JSValue>::cast(element); 1448 Handle<JSValue> jsvalue = Handle<JSValue>::cast(element);
1451 Handle<SharedFunctionInfo> shared = 1449 Handle<SharedFunctionInfo> shared =
1452 UnwrapSharedFunctionInfoFromJSValue(jsvalue); 1450 UnwrapSharedFunctionInfoFromJSValue(jsvalue);
1453 1451
1454 if (function->Inlines(*shared)) { 1452 if (function->Inlines(*shared)) {
1455 SetElementSloppy(result, i, Handle<Smi>(Smi::FromInt(status), isolate)); 1453 SetElementSloppy(result, i, Handle<Smi>(Smi::FromInt(status), isolate));
1456 return true; 1454 return true;
1457 } 1455 }
1458 } 1456 });
1459 return false; 1457 return false;
1460 } 1458 }
1461 1459
1462 1460
1463 // Iterates over handler chain and removes all elements that are inside 1461 // Iterates over handler chain and removes all elements that are inside
1464 // frames being dropped. 1462 // frames being dropped.
1465 static bool FixTryCatchHandler(StackFrame* top_frame, 1463 static bool FixTryCatchHandler(StackFrame* top_frame,
1466 StackFrame* bottom_frame) { 1464 StackFrame* bottom_frame) {
1467 Address* pointer_address = 1465 Address* pointer_address =
1468 &Memory::Address_at(top_frame->isolate()->get_address_from_id( 1466 &Memory::Address_at(top_frame->isolate()->get_address_from_id(
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 return NULL; 1647 return NULL;
1650 } 1648 }
1651 bool FrameUsesNewTarget(StackFrame* frame) { 1649 bool FrameUsesNewTarget(StackFrame* frame) {
1652 if (!frame->is_java_script()) return false; 1650 if (!frame->is_java_script()) return false;
1653 JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame); 1651 JavaScriptFrame* jsframe = JavaScriptFrame::cast(frame);
1654 Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared()); 1652 Handle<SharedFunctionInfo> old_shared(jsframe->function()->shared());
1655 Isolate* isolate = old_shared->GetIsolate(); 1653 Isolate* isolate = old_shared->GetIsolate();
1656 int len = GetArrayLength(old_shared_array_); 1654 int len = GetArrayLength(old_shared_array_);
1657 // Find corresponding new shared function info and return whether it 1655 // Find corresponding new shared function info and return whether it
1658 // references new.target. 1656 // references new.target.
1659 for (int i = 0; i < len; i++) { 1657 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < len, i++, {
1660 HandleScope scope(isolate);
1661 Handle<Object> old_element = 1658 Handle<Object> old_element =
1662 JSReceiver::GetElement(isolate, old_shared_array_, i) 1659 JSReceiver::GetElement(isolate, old_shared_array_, i)
1663 .ToHandleChecked(); 1660 .ToHandleChecked();
1664 if (!old_shared.is_identical_to(UnwrapSharedFunctionInfoFromJSValue( 1661 if (!old_shared.is_identical_to(UnwrapSharedFunctionInfoFromJSValue(
1665 Handle<JSValue>::cast(old_element)))) { 1662 Handle<JSValue>::cast(old_element)))) {
1666 continue; 1663 continue;
1667 } 1664 }
1668 1665
1669 Handle<Object> new_element = 1666 Handle<Object> new_element =
1670 JSReceiver::GetElement(isolate, new_shared_array_, i) 1667 JSReceiver::GetElement(isolate, new_shared_array_, i)
1671 .ToHandleChecked(); 1668 .ToHandleChecked();
1672 if (new_element->IsUndefined()) return false; 1669 if (new_element->IsUndefined()) return false;
1673 Handle<SharedFunctionInfo> new_shared = 1670 Handle<SharedFunctionInfo> new_shared =
1674 UnwrapSharedFunctionInfoFromJSValue( 1671 UnwrapSharedFunctionInfoFromJSValue(
1675 Handle<JSValue>::cast(new_element)); 1672 Handle<JSValue>::cast(new_element));
1676 if (new_shared->scope_info()->HasNewTarget()) { 1673 if (new_shared->scope_info()->HasNewTarget()) {
1677 SetElementSloppy( 1674 SetElementSloppy(
1678 result_, i, 1675 result_, i,
1679 Handle<Smi>( 1676 Handle<Smi>(
1680 Smi::FromInt( 1677 Smi::FromInt(
1681 LiveEdit::FUNCTION_BLOCKED_NO_NEW_TARGET_ON_RESTART), 1678 LiveEdit::FUNCTION_BLOCKED_NO_NEW_TARGET_ON_RESTART),
1682 isolate)); 1679 isolate));
1683 return true; 1680 return true;
1684 } 1681 }
1685 return false; 1682 return false;
1686 } 1683 });
1687 return false; 1684 return false;
1688 } 1685 }
1689 1686
1690 private: 1687 private:
1691 Handle<JSArray> old_shared_array_; 1688 Handle<JSArray> old_shared_array_;
1692 Handle<JSArray> new_shared_array_; 1689 Handle<JSArray> new_shared_array_;
1693 Handle<JSArray> result_; 1690 Handle<JSArray> result_;
1694 }; 1691 };
1695 1692
1696 1693
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 isolate_->active_function_info_listener()->FunctionCode(code); 2032 isolate_->active_function_info_listener()->FunctionCode(code);
2036 } 2033 }
2037 2034
2038 2035
2039 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2036 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2040 return isolate->active_function_info_listener() != NULL; 2037 return isolate->active_function_info_listener() != NULL;
2041 } 2038 }
2042 2039
2043 } // namespace internal 2040 } // namespace internal
2044 } // namespace v8 2041 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.cc ('k') | src/isolate.h » ('j') | src/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698