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

Side by Side Diff: src/liveedit.cc

Issue 1549029: Revert r4358. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 8 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 | « no previous file | no next file » | 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // implicit pointers. 440 // implicit pointers.
441 HeapIterator iterator; 441 HeapIterator iterator;
442 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 442 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
443 obj->Iterate(&visitor); 443 obj->Iterate(&visitor);
444 } 444 }
445 445
446 visitor.Replace(substitution); 446 visitor.Replace(substitution);
447 } 447 }
448 448
449 449
450 // Check whether the code is natural function code (not a lazy-compile stub
451 // code).
452 static bool IsJSFunctionCode(Code* code) {
453 return code->kind() == Code::FUNCTION;
454 }
455
456
457 void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array, 450 void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
458 Handle<JSArray> shared_info_array) { 451 Handle<JSArray> shared_info_array) {
459 HandleScope scope; 452 HandleScope scope;
460 453
461 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); 454 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
462 SharedInfoWrapper shared_info_wrapper(shared_info_array); 455 SharedInfoWrapper shared_info_wrapper(shared_info_array);
463 456
464 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 457 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
465 458
466 459 ReplaceCodeObject(shared_info->code(),
467 if (IsJSFunctionCode(shared_info->code())) { 460 *(compile_info_wrapper.GetFunctionCode()));
468 ReplaceCodeObject(shared_info->code(),
469 *(compile_info_wrapper.GetFunctionCode()));
470 }
471
472 if (shared_info->debug_info()->IsDebugInfo()) {
473 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info()));
474 Handle<Code> new_original_code =
475 Factory::CopyCode(compile_info_wrapper.GetFunctionCode());
476 debug_info->set_original_code(*new_original_code);
477 }
478 461
479 shared_info->set_start_position(compile_info_wrapper.GetStartPosition()); 462 shared_info->set_start_position(compile_info_wrapper.GetStartPosition());
480 shared_info->set_end_position(compile_info_wrapper.GetEndPosition()); 463 shared_info->set_end_position(compile_info_wrapper.GetEndPosition());
481 464 // update breakpoints, original code, constructor stub
482 shared_info->set_construct_stub(
483 Builtins::builtin(Builtins::JSConstructStubGeneric));
484 // update breakpoints
485 } 465 }
486 466
487 467
488 // TODO(635): Eval caches its scripts (same text -- same compiled info).
489 // Make sure we clear such caches.
490 void LiveEdit::RelinkFunctionToScript(Handle<JSArray> shared_info_array, 468 void LiveEdit::RelinkFunctionToScript(Handle<JSArray> shared_info_array,
491 Handle<Script> script_handle) { 469 Handle<Script> script_handle) {
492 SharedInfoWrapper shared_info_wrapper(shared_info_array); 470 SharedInfoWrapper shared_info_wrapper(shared_info_array);
493 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); 471 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
494 472
495 shared_info->set_script(*script_handle); 473 shared_info->set_script(*script_handle);
496 } 474 }
497 475
498 476
499 // For a script text change (defined as position_change_array), translates 477 // For a script text change (defined as position_change_array), translates
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 int new_function_start = TranslatePosition(old_function_start, 644 int new_function_start = TranslatePosition(old_function_start,
667 position_change_array); 645 position_change_array);
668 info->set_start_position(new_function_start); 646 info->set_start_position(new_function_start);
669 info->set_end_position(TranslatePosition(info->end_position(), 647 info->set_end_position(TranslatePosition(info->end_position(),
670 position_change_array)); 648 position_change_array));
671 649
672 info->set_function_token_position( 650 info->set_function_token_position(
673 TranslatePosition(info->function_token_position(), 651 TranslatePosition(info->function_token_position(),
674 position_change_array)); 652 position_change_array));
675 653
676 if (IsJSFunctionCode(info->code())) { 654 // Patch relocation info section of the code.
677 // Patch relocation info section of the code. 655 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()),
678 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), 656 position_change_array);
679 position_change_array); 657 if (*patched_code != info->code()) {
680 if (*patched_code != info->code()) { 658 // Replace all references to the code across the heap. In particular,
681 // Replace all references to the code across the heap. In particular, 659 // some stubs may refer to this code and this code may be being executed
682 // some stubs may refer to this code and this code may be being executed 660 // on stack (it is safe to substitute the code object on stack, because
683 // on stack (it is safe to substitute the code object on stack, because 661 // we only change the structure of rinfo and leave instructions untouched).
684 // we only change the structure of rinfo and leave instructions 662 ReplaceCodeObject(info->code(), *patched_code);
685 // untouched).
686 ReplaceCodeObject(info->code(), *patched_code);
687 }
688 } 663 }
689 664
690 665
691 Handle<JSArray> result = Factory::NewJSArray(0); 666 Handle<JSArray> result = Factory::NewJSArray(0);
692 int result_len = 0; 667 int result_len = 0;
693 668
694 if (info->debug_info()->IsDebugInfo()) { 669 if (info->debug_info()->IsDebugInfo()) {
695 Handle<DebugInfo> debug_info(DebugInfo::cast(info->debug_info())); 670 Handle<DebugInfo> debug_info(DebugInfo::cast(info->debug_info()));
696 Handle<Code> patched_orig_code = 671 Handle<Code> patched_orig_code =
697 PatchPositionsInCode(Handle<Code>(debug_info->original_code()), 672 PatchPositionsInCode(Handle<Code>(debug_info->original_code()),
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 1024
1050 bool LiveEditFunctionTracker::IsActive() { 1025 bool LiveEditFunctionTracker::IsActive() {
1051 return false; 1026 return false;
1052 } 1027 }
1053 1028
1054 #endif // ENABLE_DEBUGGER_SUPPORT 1029 #endif // ENABLE_DEBUGGER_SUPPORT
1055 1030
1056 1031
1057 1032
1058 } } // namespace v8::internal 1033 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698