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

Side by Side Diff: src/liveedit.cc

Issue 16337005: Deprecate FACTORY helper macro. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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 | « src/jsregexp.cc ('k') | src/messages.h » ('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 // 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 624
625 // Unwraps JSValue object, returning its field "value" 625 // Unwraps JSValue object, returning its field "value"
626 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { 626 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) {
627 return Handle<Object>(jsValue->value(), jsValue->GetIsolate()); 627 return Handle<Object>(jsValue->value(), jsValue->GetIsolate());
628 } 628 }
629 629
630 630
631 // Wraps any object into a OpaqueReference, that will hide the object 631 // Wraps any object into a OpaqueReference, that will hide the object
632 // from JavaScript. 632 // from JavaScript.
633 static Handle<JSValue> WrapInJSValue(Handle<Object> object) { 633 static Handle<JSValue> WrapInJSValue(Handle<Object> object) {
634 Handle<JSFunction> constructor = 634 Isolate* isolate = Isolate::Current();
635 Isolate::Current()->opaque_reference_function(); 635 Handle<JSFunction> constructor = isolate->opaque_reference_function();
636 Handle<JSValue> result = 636 Handle<JSValue> result =
637 Handle<JSValue>::cast(FACTORY->NewJSObject(constructor)); 637 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
638 result->set_value(*object); 638 result->set_value(*object);
639 return result; 639 return result;
640 } 640 }
641 641
642 642
643 static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue( 643 static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue(
644 Handle<JSValue> jsValue) { 644 Handle<JSValue> jsValue) {
645 Object* shared = jsValue->value(); 645 Object* shared = jsValue->value();
646 CHECK(shared->IsSharedFunctionInfo()); 646 CHECK(shared->IsSharedFunctionInfo());
647 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared)); 647 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared));
648 } 648 }
649 649
650 650
651 static int GetArrayLength(Handle<JSArray> array) { 651 static int GetArrayLength(Handle<JSArray> array) {
652 Object* length = array->length(); 652 Object* length = array->length();
653 CHECK(length->IsSmi()); 653 CHECK(length->IsSmi());
654 return Smi::cast(length)->value(); 654 return Smi::cast(length)->value();
655 } 655 }
656 656
657 657
658 // Simple helper class that creates more or less typed structures over 658 // Simple helper class that creates more or less typed structures over
659 // JSArray object. This is an adhoc method of passing structures from C++ 659 // JSArray object. This is an adhoc method of passing structures from C++
660 // to JavaScript. 660 // to JavaScript.
661 template<typename S> 661 template<typename S>
662 class JSArrayBasedStruct { 662 class JSArrayBasedStruct {
663 public: 663 public:
664 static S Create() { 664 static S Create() {
665 Handle<JSArray> array = FACTORY->NewJSArray(S::kSize_); 665 Factory* factory = Isolate::Current()->factory();
666 Handle<JSArray> array = factory->NewJSArray(S::kSize_);
666 return S(array); 667 return S(array);
667 } 668 }
668 static S cast(Object* object) { 669 static S cast(Object* object) {
669 JSArray* array = JSArray::cast(object); 670 JSArray* array = JSArray::cast(object);
670 Handle<JSArray> array_handle(array); 671 Handle<JSArray> array_handle(array);
671 return S(array_handle); 672 return S(array_handle);
672 } 673 }
673 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { 674 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) {
674 } 675 }
675 Handle<JSArray> GetJSArray() { 676 Handle<JSArray> GetJSArray() {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); 1287 ReplaceCodeObject(Handle<Code>(shared_info->code()), code);
1287 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); 1288 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo();
1288 if (code_scope_info->IsFixedArray()) { 1289 if (code_scope_info->IsFixedArray()) {
1289 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); 1290 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info));
1290 } 1291 }
1291 } 1292 }
1292 1293
1293 if (shared_info->debug_info()->IsDebugInfo()) { 1294 if (shared_info->debug_info()->IsDebugInfo()) {
1294 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); 1295 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info()));
1295 Handle<Code> new_original_code = 1296 Handle<Code> new_original_code =
1296 FACTORY->CopyCode(compile_info_wrapper.GetFunctionCode()); 1297 isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode());
1297 debug_info->set_original_code(*new_original_code); 1298 debug_info->set_original_code(*new_original_code);
1298 } 1299 }
1299 1300
1300 int start_position = compile_info_wrapper.GetStartPosition(); 1301 int start_position = compile_info_wrapper.GetStartPosition();
1301 int end_position = compile_info_wrapper.GetEndPosition(); 1302 int end_position = compile_info_wrapper.GetEndPosition();
1302 shared_info->set_start_position(start_position); 1303 shared_info->set_start_position(start_position);
1303 shared_info->set_end_position(end_position); 1304 shared_info->set_end_position(end_position);
1304 1305
1305 LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, isolate); 1306 LiteralFixer::PatchLiterals(&compile_info_wrapper, shared_info, isolate);
1306 1307
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 1454
1454 static const int kBufferGap = RelocInfoWriter::kMaxSize; 1455 static const int kBufferGap = RelocInfoWriter::kMaxSize;
1455 static const int kMaximalBufferSize = 512*MB; 1456 static const int kMaximalBufferSize = 512*MB;
1456 }; 1457 };
1457 1458
1458 // Patch positions in code (changes relocation info section) and possibly 1459 // Patch positions in code (changes relocation info section) and possibly
1459 // returns new instance of code. 1460 // returns new instance of code.
1460 static Handle<Code> PatchPositionsInCode( 1461 static Handle<Code> PatchPositionsInCode(
1461 Handle<Code> code, 1462 Handle<Code> code,
1462 Handle<JSArray> position_change_array) { 1463 Handle<JSArray> position_change_array) {
1464 Isolate* isolate = code->GetIsolate();
1463 1465
1464 RelocInfoBuffer buffer_writer(code->relocation_size(), 1466 RelocInfoBuffer buffer_writer(code->relocation_size(),
1465 code->instruction_start()); 1467 code->instruction_start());
1466 1468
1467 { 1469 {
1468 AssertNoAllocation no_allocations_please; 1470 AssertNoAllocation no_allocations_please;
1469 for (RelocIterator it(*code); !it.done(); it.next()) { 1471 for (RelocIterator it(*code); !it.done(); it.next()) {
1470 RelocInfo* rinfo = it.rinfo(); 1472 RelocInfo* rinfo = it.rinfo();
1471 if (RelocInfo::IsPosition(rinfo->rmode())) { 1473 if (RelocInfo::IsPosition(rinfo->rmode())) {
1472 int position = static_cast<int>(rinfo->data()); 1474 int position = static_cast<int>(rinfo->data());
(...skipping 14 matching lines...) Expand all
1487 Vector<byte> buffer = buffer_writer.GetResult(); 1489 Vector<byte> buffer = buffer_writer.GetResult();
1488 1490
1489 if (buffer.length() == code->relocation_size()) { 1491 if (buffer.length() == code->relocation_size()) {
1490 // Simply patch relocation area of code. 1492 // Simply patch relocation area of code.
1491 OS::MemCopy(code->relocation_start(), buffer.start(), buffer.length()); 1493 OS::MemCopy(code->relocation_start(), buffer.start(), buffer.length());
1492 return code; 1494 return code;
1493 } else { 1495 } else {
1494 // Relocation info section now has different size. We cannot simply 1496 // Relocation info section now has different size. We cannot simply
1495 // rewrite it inside code object. Instead we have to create a new 1497 // rewrite it inside code object. Instead we have to create a new
1496 // code object. 1498 // code object.
1497 Handle<Code> result(FACTORY->CopyCode(code, buffer)); 1499 Handle<Code> result(isolate->factory()->CopyCode(code, buffer));
1498 return result; 1500 return result;
1499 } 1501 }
1500 } 1502 }
1501 1503
1502 1504
1503 MaybeObject* LiveEdit::PatchFunctionPositions( 1505 MaybeObject* LiveEdit::PatchFunctionPositions(
1504 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { 1506 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) {
1505 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { 1507 if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
1506 return Isolate::Current()->ThrowIllegalOperation(); 1508 return Isolate::Current()->ThrowIllegalOperation();
1507 } 1509 }
(...skipping 27 matching lines...) Expand all
1535 // untouched). 1537 // untouched).
1536 ReplaceCodeObject(Handle<Code>(info->code()), patched_code); 1538 ReplaceCodeObject(Handle<Code>(info->code()), patched_code);
1537 } 1539 }
1538 } 1540 }
1539 1541
1540 return HEAP->undefined_value(); 1542 return HEAP->undefined_value();
1541 } 1543 }
1542 1544
1543 1545
1544 static Handle<Script> CreateScriptCopy(Handle<Script> original) { 1546 static Handle<Script> CreateScriptCopy(Handle<Script> original) {
1547 Isolate* isolate = original->GetIsolate();
1548
1545 Handle<String> original_source(String::cast(original->source())); 1549 Handle<String> original_source(String::cast(original->source()));
1546 1550 Handle<Script> copy = isolate->factory()->NewScript(original_source);
1547 Handle<Script> copy = FACTORY->NewScript(original_source);
1548 1551
1549 copy->set_name(original->name()); 1552 copy->set_name(original->name());
1550 copy->set_line_offset(original->line_offset()); 1553 copy->set_line_offset(original->line_offset());
1551 copy->set_column_offset(original->column_offset()); 1554 copy->set_column_offset(original->column_offset());
1552 copy->set_data(original->data()); 1555 copy->set_data(original->data());
1553 copy->set_type(original->type()); 1556 copy->set_type(original->type());
1554 copy->set_context_data(original->context_data()); 1557 copy->set_context_data(original->context_data());
1555 copy->set_compilation_type(original->compilation_type()); 1558 copy->set_compilation_type(original->compilation_type());
1556 copy->set_eval_from_shared(original->eval_from_shared()); 1559 copy->set_eval_from_shared(original->eval_from_shared());
1557 copy->set_eval_from_instructions_offset( 1560 copy->set_eval_from_instructions_offset(
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 if (inactive_threads_checker.HasBlockedFunctions()) { 2003 if (inactive_threads_checker.HasBlockedFunctions()) {
2001 return result; 2004 return result;
2002 } 2005 }
2003 2006
2004 // Try to drop activations from the current stack. 2007 // Try to drop activations from the current stack.
2005 const char* error_message = 2008 const char* error_message =
2006 DropActivationsInActiveThread(shared_info_array, result, do_drop, zone); 2009 DropActivationsInActiveThread(shared_info_array, result, do_drop, zone);
2007 if (error_message != NULL) { 2010 if (error_message != NULL) {
2008 // Add error message as an array extra element. 2011 // Add error message as an array extra element.
2009 Vector<const char> vector_message(error_message, StrLength(error_message)); 2012 Vector<const char> vector_message(error_message, StrLength(error_message));
2010 Handle<String> str = FACTORY->NewStringFromAscii(vector_message); 2013 Handle<String> str = isolate->factory()->NewStringFromAscii(vector_message);
2011 SetElementNonStrict(result, len, str); 2014 SetElementNonStrict(result, len, str);
2012 } 2015 }
2013 return result; 2016 return result;
2014 } 2017 }
2015 2018
2016 2019
2017 // Describes a single callframe a target. Not finding this frame 2020 // Describes a single callframe a target. Not finding this frame
2018 // means an error. 2021 // means an error.
2019 class SingleFrameTarget { 2022 class SingleFrameTarget {
2020 public: 2023 public:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2122
2120 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2123 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2121 return false; 2124 return false;
2122 } 2125 }
2123 2126
2124 #endif // ENABLE_DEBUGGER_SUPPORT 2127 #endif // ENABLE_DEBUGGER_SUPPORT
2125 2128
2126 2129
2127 2130
2128 } } // namespace v8::internal 2131 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.cc ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698