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

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

Issue 1976933002: [liveedit] patch source position table for bytecode arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@liveedit
Patch Set: Created 4 years, 7 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 | « no previous file | test/mjsunit/mjsunit.status » ('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"
11 #include "src/compiler.h" 11 #include "src/compiler.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/deoptimizer.h" 13 #include "src/deoptimizer.h"
14 #include "src/frames-inl.h" 14 #include "src/frames-inl.h"
15 #include "src/global-handles.h" 15 #include "src/global-handles.h"
16 #include "src/interpreter/source-position-table.h"
16 #include "src/isolate-inl.h" 17 #include "src/isolate-inl.h"
17 #include "src/messages.h" 18 #include "src/messages.h"
18 #include "src/parsing/parser.h" 19 #include "src/parsing/parser.h"
19 #include "src/v8.h" 20 #include "src/v8.h"
20 #include "src/v8memory.h" 21 #include "src/v8memory.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 25
25 void SetElementSloppy(Handle<JSObject> object, 26 void SetElementSloppy(Handle<JSObject> object,
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1277 }
1277 1278
1278 RelocInfoWriter reloc_info_writer_; 1279 RelocInfoWriter reloc_info_writer_;
1279 byte* buffer_; 1280 byte* buffer_;
1280 int buffer_size_; 1281 int buffer_size_;
1281 1282
1282 static const int kBufferGap = RelocInfoWriter::kMaxSize; 1283 static const int kBufferGap = RelocInfoWriter::kMaxSize;
1283 static const int kMaximalBufferSize = 512*MB; 1284 static const int kMaximalBufferSize = 512*MB;
1284 }; 1285 };
1285 1286
1286 1287 namespace {
1287 // Patch positions in code (changes relocation info section) and possibly 1288 // Patch positions in code (changes relocation info section) and possibly
1288 // returns new instance of code. 1289 // returns new instance of code.
1289 static Handle<Code> PatchPositionsInCode( 1290 Handle<Code> PatchPositionsInCode(Handle<Code> code,
1290 Handle<Code> code, 1291 Handle<JSArray> position_change_array) {
1291 Handle<JSArray> position_change_array) {
1292 Isolate* isolate = code->GetIsolate(); 1292 Isolate* isolate = code->GetIsolate();
1293 1293
1294 RelocInfoBuffer buffer_writer(code->relocation_size(), 1294 RelocInfoBuffer buffer_writer(code->relocation_size(),
1295 code->instruction_start()); 1295 code->instruction_start());
1296 1296
1297 { 1297 {
1298 for (RelocIterator it(*code); !it.done(); it.next()) { 1298 for (RelocIterator it(*code); !it.done(); it.next()) {
1299 RelocInfo* rinfo = it.rinfo(); 1299 RelocInfo* rinfo = it.rinfo();
1300 if (RelocInfo::IsPosition(rinfo->rmode())) { 1300 if (RelocInfo::IsPosition(rinfo->rmode())) {
1301 int position = static_cast<int>(rinfo->data()); 1301 int position = static_cast<int>(rinfo->data());
(...skipping 20 matching lines...) Expand all
1322 return code; 1322 return code;
1323 } else { 1323 } else {
1324 // Relocation info section now has different size. We cannot simply 1324 // Relocation info section now has different size. We cannot simply
1325 // rewrite it inside code object. Instead we have to create a new 1325 // rewrite it inside code object. Instead we have to create a new
1326 // code object. 1326 // code object.
1327 Handle<Code> result(isolate->factory()->CopyCode(code, buffer)); 1327 Handle<Code> result(isolate->factory()->CopyCode(code, buffer));
1328 return result; 1328 return result;
1329 } 1329 }
1330 } 1330 }
1331 1331
1332 void PatchPositionsInBytecodeArray(Handle<BytecodeArray> bytecode,
1333 Handle<JSArray> position_change_array) {
1334 Isolate* isolate = bytecode->GetIsolate();
1335 Zone zone(isolate->allocator());
1336 interpreter::SourcePositionTableBuilder builder(isolate, &zone);
1337
1338 for (interpreter::SourcePositionTableIterator iterator(
1339 bytecode->source_position_table());
1340 !iterator.done(); iterator.Advance()) {
1341 int position = iterator.source_position();
1342 int new_position = TranslatePosition(position, position_change_array);
1343 builder.AddPosition(iterator.bytecode_offset(), new_position,
1344 iterator.is_statement());
1345 }
1346
1347 bytecode->set_source_position_table(*builder.ToSourcePositionTable());
1348 }
1349 } // namespace
1332 1350
1333 void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array, 1351 void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array,
1334 Handle<JSArray> position_change_array) { 1352 Handle<JSArray> position_change_array) {
1335 SharedInfoWrapper shared_info_wrapper(shared_info_array); 1353 SharedInfoWrapper shared_info_wrapper(shared_info_array);
1336 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); 1354 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo();
1337 1355
1338 int old_function_start = info->start_position(); 1356 int old_function_start = info->start_position();
1339 int new_function_start = TranslatePosition(old_function_start, 1357 int new_function_start = TranslatePosition(old_function_start,
1340 position_change_array); 1358 position_change_array);
1341 int new_function_end = TranslatePosition(info->end_position(), 1359 int new_function_end = TranslatePosition(info->end_position(),
(...skipping 10 matching lines...) Expand all
1352 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), 1370 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()),
1353 position_change_array); 1371 position_change_array);
1354 if (*patched_code != info->code()) { 1372 if (*patched_code != info->code()) {
1355 // Replace all references to the code across the heap. In particular, 1373 // Replace all references to the code across the heap. In particular,
1356 // some stubs may refer to this code and this code may be being executed 1374 // some stubs may refer to this code and this code may be being executed
1357 // on stack (it is safe to substitute the code object on stack, because 1375 // on stack (it is safe to substitute the code object on stack, because
1358 // we only change the structure of rinfo and leave instructions 1376 // we only change the structure of rinfo and leave instructions
1359 // untouched). 1377 // untouched).
1360 ReplaceCodeObject(Handle<Code>(info->code()), patched_code); 1378 ReplaceCodeObject(Handle<Code>(info->code()), patched_code);
1361 } 1379 }
1380 } else if (info->HasBytecodeArray()) {
1381 PatchPositionsInBytecodeArray(Handle<BytecodeArray>(info->bytecode_array()),
1382 position_change_array);
1362 } 1383 }
1363 } 1384 }
1364 1385
1365 1386
1366 static Handle<Script> CreateScriptCopy(Handle<Script> original) { 1387 static Handle<Script> CreateScriptCopy(Handle<Script> original) {
1367 Isolate* isolate = original->GetIsolate(); 1388 Isolate* isolate = original->GetIsolate();
1368 1389
1369 Handle<String> original_source(String::cast(original->source())); 1390 Handle<String> original_source(String::cast(original->source()));
1370 Handle<Script> copy = isolate->factory()->NewScript(original_source); 1391 Handle<Script> copy = isolate->factory()->NewScript(original_source);
1371 1392
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 } 2058 }
2038 } 2059 }
2039 2060
2040 2061
2041 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2062 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2042 return isolate->active_function_info_listener() != NULL; 2063 return isolate->active_function_info_listener() != NULL;
2043 } 2064 }
2044 2065
2045 } // namespace internal 2066 } // namespace internal
2046 } // namespace v8 2067 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698