OLD | NEW |
---|---|
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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 output->SetSubrange1(common_prefix_len, new_len1); | 342 output->SetSubrange1(common_prefix_len, new_len1); |
343 output->SetSubrange2(common_prefix_len, new_len2); | 343 output->SetSubrange2(common_prefix_len, new_len2); |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 | 347 |
348 // A helper class that writes chunk numbers into JSArray. | 348 // A helper class that writes chunk numbers into JSArray. |
349 // Each chunk is stored as 3 array elements: (pos1_begin, pos1_end, pos2_end). | 349 // Each chunk is stored as 3 array elements: (pos1_begin, pos1_end, pos2_end). |
350 class CompareOutputArrayWriter { | 350 class CompareOutputArrayWriter { |
351 public: | 351 public: |
352 CompareOutputArrayWriter() | 352 explicit CompareOutputArrayWriter(Isolate* isolate) |
353 : array_(FACTORY->NewJSArray(10)), current_size_(0) {} | 353 : array_(isolate->factory()->NewJSArray(10)), current_size_(0) {} |
354 | 354 |
355 Handle<JSArray> GetResult() { | 355 Handle<JSArray> GetResult() { |
356 return array_; | 356 return array_; |
357 } | 357 } |
358 | 358 |
359 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { | 359 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { |
360 Isolate* isolate = array_->GetIsolate(); | |
360 SetElementNonStrict(array_, | 361 SetElementNonStrict(array_, |
361 current_size_, | 362 current_size_, |
362 Handle<Object>(Smi::FromInt(char_pos1))); | 363 Handle<Object>(Smi::FromInt(char_pos1), isolate)); |
363 SetElementNonStrict(array_, | 364 SetElementNonStrict(array_, |
364 current_size_ + 1, | 365 current_size_ + 1, |
365 Handle<Object>(Smi::FromInt(char_pos1 + char_len1))); | 366 Handle<Object>(Smi::FromInt(char_pos1 + char_len1), |
367 isolate)); | |
366 SetElementNonStrict(array_, | 368 SetElementNonStrict(array_, |
367 current_size_ + 2, | 369 current_size_ + 2, |
368 Handle<Object>(Smi::FromInt(char_pos2 + char_len2))); | 370 Handle<Object>(Smi::FromInt(char_pos2 + char_len2), |
371 isolate)); | |
369 current_size_ += 3; | 372 current_size_ += 3; |
370 } | 373 } |
371 | 374 |
372 private: | 375 private: |
373 Handle<JSArray> array_; | 376 Handle<JSArray> array_; |
374 int current_size_; | 377 int current_size_; |
375 }; | 378 }; |
376 | 379 |
377 | 380 |
378 // Represents 2 strings as 2 arrays of tokens. | 381 // Represents 2 strings as 2 arrays of tokens. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 }; | 523 }; |
521 | 524 |
522 | 525 |
523 // Stores compare result in JSArray. For each chunk tries to conduct | 526 // Stores compare result in JSArray. For each chunk tries to conduct |
524 // a fine-grained nested diff token-wise. | 527 // a fine-grained nested diff token-wise. |
525 class TokenizingLineArrayCompareOutput : public SubrangableOutput { | 528 class TokenizingLineArrayCompareOutput : public SubrangableOutput { |
526 public: | 529 public: |
527 TokenizingLineArrayCompareOutput(LineEndsWrapper line_ends1, | 530 TokenizingLineArrayCompareOutput(LineEndsWrapper line_ends1, |
528 LineEndsWrapper line_ends2, | 531 LineEndsWrapper line_ends2, |
529 Handle<String> s1, Handle<String> s2) | 532 Handle<String> s1, Handle<String> s2) |
530 : line_ends1_(line_ends1), line_ends2_(line_ends2), s1_(s1), s2_(s2), | 533 : array_writer_(s1->GetIsolate()), |
534 line_ends1_(line_ends1), line_ends2_(line_ends2), s1_(s1), s2_(s2), | |
531 subrange_offset1_(0), subrange_offset2_(0) { | 535 subrange_offset1_(0), subrange_offset2_(0) { |
532 } | 536 } |
533 | 537 |
534 void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) { | 538 void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) { |
535 line_pos1 += subrange_offset1_; | 539 line_pos1 += subrange_offset1_; |
536 line_pos2 += subrange_offset2_; | 540 line_pos2 += subrange_offset2_; |
537 | 541 |
538 int char_pos1 = line_ends1_.GetLineStart(line_pos1); | 542 int char_pos1 = line_ends1_.GetLineStart(line_pos1); |
539 int char_pos2 = line_ends2_.GetLineStart(line_pos2); | 543 int char_pos2 = line_ends2_.GetLineStart(line_pos2); |
540 int char_len1 = line_ends1_.GetLineStart(line_pos1 + line_len1) - char_pos1; | 544 int char_len1 = line_ends1_.GetLineStart(line_pos1 + line_len1) - char_pos1; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 tracker.RecordRootFunctionInfo(info.code()); | 617 tracker.RecordRootFunctionInfo(info.code()); |
614 } else { | 618 } else { |
615 info.isolate()->StackOverflow(); | 619 info.isolate()->StackOverflow(); |
616 } | 620 } |
617 } | 621 } |
618 } | 622 } |
619 | 623 |
620 | 624 |
621 // Unwraps JSValue object, returning its field "value" | 625 // Unwraps JSValue object, returning its field "value" |
622 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { | 626 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { |
623 return Handle<Object>(jsValue->value()); | 627 return Handle<Object>(jsValue->value(), jsValue->GetIsolate()); |
624 } | 628 } |
625 | 629 |
626 | 630 |
627 // Wraps any object into a OpaqueReference, that will hide the object | 631 // Wraps any object into a OpaqueReference, that will hide the object |
628 // from JavaScript. | 632 // from JavaScript. |
629 static Handle<JSValue> WrapInJSValue(Handle<Object> object) { | 633 static Handle<JSValue> WrapInJSValue(Handle<Object> object) { |
630 Handle<JSFunction> constructor = | 634 Handle<JSFunction> constructor = |
631 Isolate::Current()->opaque_reference_function(); | 635 Isolate::Current()->opaque_reference_function(); |
632 Handle<JSValue> result = | 636 Handle<JSValue> result = |
633 Handle<JSValue>::cast(FACTORY->NewJSObject(constructor)); | 637 Handle<JSValue>::cast(FACTORY->NewJSObject(constructor)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
675 return array_->GetIsolate(); | 679 return array_->GetIsolate(); |
676 } | 680 } |
677 | 681 |
678 protected: | 682 protected: |
679 void SetField(int field_position, Handle<Object> value) { | 683 void SetField(int field_position, Handle<Object> value) { |
680 SetElementNonStrict(array_, field_position, value); | 684 SetElementNonStrict(array_, field_position, value); |
681 } | 685 } |
682 void SetSmiValueField(int field_position, int value) { | 686 void SetSmiValueField(int field_position, int value) { |
683 SetElementNonStrict(array_, | 687 SetElementNonStrict(array_, |
684 field_position, | 688 field_position, |
685 Handle<Smi>(Smi::FromInt(value))); | 689 Handle<Smi>(Smi::FromInt(value), isolate())); |
686 } | 690 } |
687 Object* GetField(int field_position) { | 691 Object* GetField(int field_position) { |
688 return array_->GetElementNoExceptionThrown(field_position); | 692 return array_->GetElementNoExceptionThrown(field_position); |
689 } | 693 } |
690 int GetSmiValueField(int field_position) { | 694 int GetSmiValueField(int field_position) { |
691 Object* res = GetField(field_position); | 695 Object* res = GetField(field_position); |
692 CHECK(res->IsSmi()); | 696 CHECK(res->IsSmi()); |
693 return Smi::cast(res)->value(); | 697 return Smi::cast(res)->value(); |
694 } | 698 } |
695 | 699 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 static const int kEndPositionOffset_ = 2; | 815 static const int kEndPositionOffset_ = 2; |
812 static const int kSharedInfoOffset_ = 3; | 816 static const int kSharedInfoOffset_ = 3; |
813 static const int kSize_ = 4; | 817 static const int kSize_ = 4; |
814 | 818 |
815 friend class JSArrayBasedStruct<SharedInfoWrapper>; | 819 friend class JSArrayBasedStruct<SharedInfoWrapper>; |
816 }; | 820 }; |
817 | 821 |
818 | 822 |
819 class FunctionInfoListener { | 823 class FunctionInfoListener { |
820 public: | 824 public: |
821 FunctionInfoListener() { | 825 explicit FunctionInfoListener(Isolate* isolate) { |
822 current_parent_index_ = -1; | 826 current_parent_index_ = -1; |
823 len_ = 0; | 827 len_ = 0; |
824 result_ = FACTORY->NewJSArray(10); | 828 result_ = isolate->factory()->NewJSArray(10); |
825 } | 829 } |
826 | 830 |
827 void FunctionStarted(FunctionLiteral* fun) { | 831 void FunctionStarted(FunctionLiteral* fun) { |
828 HandleScope scope(result_->GetIsolate()); | 832 HandleScope scope(isolate()); |
829 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 833 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); |
830 info.SetInitialProperties(fun->name(), fun->start_position(), | 834 info.SetInitialProperties(fun->name(), fun->start_position(), |
831 fun->end_position(), fun->parameter_count(), | 835 fun->end_position(), fun->parameter_count(), |
832 fun->materialized_literal_count(), | 836 fun->materialized_literal_count(), |
833 current_parent_index_); | 837 current_parent_index_); |
834 current_parent_index_ = len_; | 838 current_parent_index_ = len_; |
835 SetElementNonStrict(result_, len_, info.GetJSArray()); | 839 SetElementNonStrict(result_, len_, info.GetJSArray()); |
836 len_++; | 840 len_++; |
837 } | 841 } |
838 | 842 |
839 void FunctionDone() { | 843 void FunctionDone() { |
840 HandleScope scope(result_->GetIsolate()); | 844 HandleScope scope(isolate()); |
841 FunctionInfoWrapper info = | 845 FunctionInfoWrapper info = |
842 FunctionInfoWrapper::cast( | 846 FunctionInfoWrapper::cast( |
843 result_->GetElementNoExceptionThrown(current_parent_index_)); | 847 result_->GetElementNoExceptionThrown(current_parent_index_)); |
844 current_parent_index_ = info.GetParentIndex(); | 848 current_parent_index_ = info.GetParentIndex(); |
845 } | 849 } |
846 | 850 |
847 // Saves only function code, because for a script function we | 851 // Saves only function code, because for a script function we |
848 // may never create a SharedFunctionInfo object. | 852 // may never create a SharedFunctionInfo object. |
849 void FunctionCode(Handle<Code> function_code) { | 853 void FunctionCode(Handle<Code> function_code) { |
850 FunctionInfoWrapper info = | 854 FunctionInfoWrapper info = |
851 FunctionInfoWrapper::cast( | 855 FunctionInfoWrapper::cast( |
852 result_->GetElementNoExceptionThrown(current_parent_index_)); | 856 result_->GetElementNoExceptionThrown(current_parent_index_)); |
853 info.SetFunctionCode(function_code, Handle<Object>(HEAP->null_value())); | 857 info.SetFunctionCode(function_code, |
858 Handle<Object>(isolate()->heap()->null_value(), | |
859 isolate())); | |
854 } | 860 } |
855 | 861 |
856 // Saves full information about a function: its code, its scope info | 862 // Saves full information about a function: its code, its scope info |
857 // and a SharedFunctionInfo object. | 863 // and a SharedFunctionInfo object. |
858 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope, | 864 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope, |
859 Zone* zone) { | 865 Zone* zone) { |
860 if (!shared->IsSharedFunctionInfo()) { | 866 if (!shared->IsSharedFunctionInfo()) { |
861 return; | 867 return; |
862 } | 868 } |
863 FunctionInfoWrapper info = | 869 FunctionInfoWrapper info = |
864 FunctionInfoWrapper::cast( | 870 FunctionInfoWrapper::cast( |
865 result_->GetElementNoExceptionThrown(current_parent_index_)); | 871 result_->GetElementNoExceptionThrown(current_parent_index_)); |
866 info.SetFunctionCode(Handle<Code>(shared->code()), | 872 info.SetFunctionCode(Handle<Code>(shared->code()), |
867 Handle<Object>(shared->scope_info())); | 873 Handle<Object>(shared->scope_info(), isolate())); |
868 info.SetSharedFunctionInfo(shared); | 874 info.SetSharedFunctionInfo(shared); |
869 | 875 |
870 Handle<Object> scope_info_list( | 876 Handle<Object> scope_info_list(SerializeFunctionScope(scope, zone), |
871 SerializeFunctionScope(shared->GetIsolate(), scope, zone)); | 877 isolate()); |
872 info.SetOuterScopeInfo(scope_info_list); | 878 info.SetOuterScopeInfo(scope_info_list); |
873 } | 879 } |
874 | 880 |
875 Handle<JSArray> GetResult() { return result_; } | 881 Handle<JSArray> GetResult() { return result_; } |
876 | 882 |
877 private: | 883 private: |
878 Object* SerializeFunctionScope(Isolate* isolate, Scope* scope, Zone* zone) { | 884 Isolate* isolate() const { return result_->GetIsolate(); } |
879 HandleScope handle_scope(isolate); | |
880 | 885 |
881 Handle<JSArray> scope_info_list = isolate->factory()->NewJSArray(10); | 886 Object* SerializeFunctionScope(Scope* scope, Zone* zone) { |
887 HandleScope handle_scope(isolate()); | |
888 | |
889 Handle<JSArray> scope_info_list = isolate()->factory()->NewJSArray(10); | |
882 int scope_info_length = 0; | 890 int scope_info_length = 0; |
883 | 891 |
884 // Saves some description of scope. It stores name and indexes of | 892 // Saves some description of scope. It stores name and indexes of |
885 // variables in the whole scope chain. Null-named slots delimit | 893 // variables in the whole scope chain. Null-named slots delimit |
886 // scopes of this chain. | 894 // scopes of this chain. |
887 Scope* outer_scope = scope->outer_scope(); | 895 Scope* outer_scope = scope->outer_scope(); |
888 if (outer_scope == NULL) { | 896 if (outer_scope == NULL) { |
889 return isolate->heap()->undefined_value(); | 897 return isolate()->heap()->undefined_value(); |
890 } | 898 } |
891 do { | 899 do { |
892 ZoneList<Variable*> stack_list(outer_scope->StackLocalCount(), zone); | 900 ZoneList<Variable*> stack_list(outer_scope->StackLocalCount(), zone); |
893 ZoneList<Variable*> context_list(outer_scope->ContextLocalCount(), zone); | 901 ZoneList<Variable*> context_list(outer_scope->ContextLocalCount(), zone); |
894 outer_scope->CollectStackAndContextLocals(&stack_list, &context_list); | 902 outer_scope->CollectStackAndContextLocals(&stack_list, &context_list); |
895 context_list.Sort(&Variable::CompareIndex); | 903 context_list.Sort(&Variable::CompareIndex); |
896 | 904 |
897 for (int i = 0; i < context_list.length(); i++) { | 905 for (int i = 0; i < context_list.length(); i++) { |
898 SetElementNonStrict(scope_info_list, | 906 SetElementNonStrict(scope_info_list, |
899 scope_info_length, | 907 scope_info_length, |
900 context_list[i]->name()); | 908 context_list[i]->name()); |
901 scope_info_length++; | 909 scope_info_length++; |
902 SetElementNonStrict( | 910 SetElementNonStrict( |
903 scope_info_list, | 911 scope_info_list, |
904 scope_info_length, | 912 scope_info_length, |
905 Handle<Smi>(Smi::FromInt(context_list[i]->index()))); | 913 Handle<Smi>(Smi::FromInt(context_list[i]->index()), isolate())); |
906 scope_info_length++; | 914 scope_info_length++; |
907 } | 915 } |
908 SetElementNonStrict(scope_info_list, | 916 SetElementNonStrict(scope_info_list, |
909 scope_info_length, | 917 scope_info_length, |
910 Handle<Object>(isolate->heap()->null_value())); | 918 Handle<Object>(isolate()->heap()->null_value(), |
919 isolate())); | |
911 scope_info_length++; | 920 scope_info_length++; |
912 | 921 |
913 outer_scope = outer_scope->outer_scope(); | 922 outer_scope = outer_scope->outer_scope(); |
914 } while (outer_scope != NULL); | 923 } while (outer_scope != NULL); |
915 | 924 |
916 return *scope_info_list; | 925 return *scope_info_list; |
917 } | 926 } |
918 | 927 |
919 Handle<JSArray> result_; | 928 Handle<JSArray> result_; |
920 int len_; | 929 int len_; |
921 int current_parent_index_; | 930 int current_parent_index_; |
922 }; | 931 }; |
923 | 932 |
924 | 933 |
925 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, | 934 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, |
926 Handle<String> source) { | 935 Handle<String> source) { |
927 Isolate* isolate = Isolate::Current(); | 936 Isolate* isolate = Isolate::Current(); |
928 | 937 |
929 FunctionInfoListener listener; | 938 FunctionInfoListener listener(isolate); |
930 Handle<Object> original_source = Handle<Object>(script->source()); | 939 Handle<Object> original_source = |
940 Handle<Object>(script->source(), isolate); | |
931 script->set_source(*source); | 941 script->set_source(*source); |
932 isolate->set_active_function_info_listener(&listener); | 942 isolate->set_active_function_info_listener(&listener); |
933 | 943 |
934 { | 944 { |
935 // Creating verbose TryCatch from public API is currently the only way to | 945 // Creating verbose TryCatch from public API is currently the only way to |
936 // force code save location. We do not use this the object directly. | 946 // force code save location. We do not use this the object directly. |
937 v8::TryCatch try_catch; | 947 v8::TryCatch try_catch; |
938 try_catch.SetVerbose(true); | 948 try_catch.SetVerbose(true); |
939 | 949 |
940 // A logical 'try' section. | 950 // A logical 'try' section. |
941 CompileScriptForTracker(isolate, script); | 951 CompileScriptForTracker(isolate, script); |
942 } | 952 } |
943 | 953 |
944 // A logical 'catch' section. | 954 // A logical 'catch' section. |
945 Handle<JSObject> rethrow_exception; | 955 Handle<JSObject> rethrow_exception; |
946 if (isolate->has_pending_exception()) { | 956 if (isolate->has_pending_exception()) { |
947 Handle<Object> exception(isolate->pending_exception()->ToObjectChecked()); | 957 Handle<Object> exception(isolate->pending_exception()->ToObjectChecked(), |
958 isolate); | |
948 MessageLocation message_location = isolate->GetMessageLocation(); | 959 MessageLocation message_location = isolate->GetMessageLocation(); |
949 | 960 |
950 isolate->clear_pending_message(); | 961 isolate->clear_pending_message(); |
951 isolate->clear_pending_exception(); | 962 isolate->clear_pending_exception(); |
952 | 963 |
953 // If possible, copy positions from message object to exception object. | 964 // If possible, copy positions from message object to exception object. |
954 if (exception->IsJSObject() && !message_location.script().is_null()) { | 965 if (exception->IsJSObject() && !message_location.script().is_null()) { |
955 rethrow_exception = Handle<JSObject>::cast(exception); | 966 rethrow_exception = Handle<JSObject>::cast(exception); |
956 | 967 |
957 Factory* factory = isolate->factory(); | 968 Factory* factory = isolate->factory(); |
958 Handle<String> start_pos_key = | 969 Handle<String> start_pos_key = |
959 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("startPosition")); | 970 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("startPosition")); |
960 Handle<String> end_pos_key = | 971 Handle<String> end_pos_key = |
961 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("endPosition")); | 972 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("endPosition")); |
962 Handle<String> script_obj_key = | 973 Handle<String> script_obj_key = |
963 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("scriptObject")); | 974 factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("scriptObject")); |
964 Handle<Smi> start_pos(Smi::FromInt(message_location.start_pos())); | 975 Handle<Smi> start_pos(Smi::FromInt(message_location.start_pos()), |
965 Handle<Smi> end_pos(Smi::FromInt(message_location.end_pos())); | 976 isolate); |
977 Handle<Smi> end_pos(Smi::FromInt(message_location.end_pos()), isolate); | |
966 Handle<JSValue> script_obj = GetScriptWrapper(message_location.script()); | 978 Handle<JSValue> script_obj = GetScriptWrapper(message_location.script()); |
967 JSReceiver::SetProperty( | 979 JSReceiver::SetProperty( |
968 rethrow_exception, start_pos_key, start_pos, NONE, kNonStrictMode); | 980 rethrow_exception, start_pos_key, start_pos, NONE, kNonStrictMode); |
969 JSReceiver::SetProperty( | 981 JSReceiver::SetProperty( |
970 rethrow_exception, end_pos_key, end_pos, NONE, kNonStrictMode); | 982 rethrow_exception, end_pos_key, end_pos, NONE, kNonStrictMode); |
971 JSReceiver::SetProperty( | 983 JSReceiver::SetProperty( |
972 rethrow_exception, script_obj_key, script_obj, NONE, kNonStrictMode); | 984 rethrow_exception, script_obj_key, script_obj, NONE, kNonStrictMode); |
973 } | 985 } |
974 } | 986 } |
975 | 987 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1545 copy->set_eval_from_instructions_offset( | 1557 copy->set_eval_from_instructions_offset( |
1546 original->eval_from_instructions_offset()); | 1558 original->eval_from_instructions_offset()); |
1547 | 1559 |
1548 return copy; | 1560 return copy; |
1549 } | 1561 } |
1550 | 1562 |
1551 | 1563 |
1552 Object* LiveEdit::ChangeScriptSource(Handle<Script> original_script, | 1564 Object* LiveEdit::ChangeScriptSource(Handle<Script> original_script, |
1553 Handle<String> new_source, | 1565 Handle<String> new_source, |
1554 Handle<Object> old_script_name) { | 1566 Handle<Object> old_script_name) { |
1567 Isolate* isolate = original_script->GetIsolate(); | |
1555 Handle<Object> old_script_object; | 1568 Handle<Object> old_script_object; |
1556 if (old_script_name->IsString()) { | 1569 if (old_script_name->IsString()) { |
1557 Handle<Script> old_script = CreateScriptCopy(original_script); | 1570 Handle<Script> old_script = CreateScriptCopy(original_script); |
1558 old_script->set_name(String::cast(*old_script_name)); | 1571 old_script->set_name(String::cast(*old_script_name)); |
1559 old_script_object = old_script; | 1572 old_script_object = old_script; |
1560 Isolate::Current()->debugger()->OnAfterCompile( | 1573 isolate->debugger()->OnAfterCompile( |
1561 old_script, Debugger::SEND_WHEN_DEBUGGING); | 1574 old_script, Debugger::SEND_WHEN_DEBUGGING); |
1562 } else { | 1575 } else { |
1563 old_script_object = Handle<Object>(HEAP->null_value()); | 1576 old_script_object = Handle<Object>(isolate->heap()->null_value(), isolate); |
Michael Starzinger
2013/02/25 10:50:58
Just use "old_script_object = isolate->factory()->
Sven Panne
2013/02/25 14:44:43
Done.
| |
1564 } | 1577 } |
1565 | 1578 |
1566 original_script->set_source(*new_source); | 1579 original_script->set_source(*new_source); |
1567 | 1580 |
1568 // Drop line ends so that they will be recalculated. | 1581 // Drop line ends so that they will be recalculated. |
1569 original_script->set_line_ends(HEAP->undefined_value()); | 1582 original_script->set_line_ends(HEAP->undefined_value()); |
1570 | 1583 |
1571 return *old_script_object; | 1584 return *old_script_object; |
1572 } | 1585 } |
1573 | 1586 |
(...skipping 25 matching lines...) Expand all Loading... | |
1599 // that matches, its status in result array is changed to status argument value. | 1612 // that matches, its status in result array is changed to status argument value. |
1600 static bool CheckActivation(Handle<JSArray> shared_info_array, | 1613 static bool CheckActivation(Handle<JSArray> shared_info_array, |
1601 Handle<JSArray> result, | 1614 Handle<JSArray> result, |
1602 StackFrame* frame, | 1615 StackFrame* frame, |
1603 LiveEdit::FunctionPatchabilityStatus status) { | 1616 LiveEdit::FunctionPatchabilityStatus status) { |
1604 if (!frame->is_java_script()) return false; | 1617 if (!frame->is_java_script()) return false; |
1605 | 1618 |
1606 Handle<JSFunction> function( | 1619 Handle<JSFunction> function( |
1607 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); | 1620 JSFunction::cast(JavaScriptFrame::cast(frame)->function())); |
1608 | 1621 |
1622 Isolate* isolate = shared_info_array->GetIsolate(); | |
1609 int len = GetArrayLength(shared_info_array); | 1623 int len = GetArrayLength(shared_info_array); |
1610 for (int i = 0; i < len; i++) { | 1624 for (int i = 0; i < len; i++) { |
1611 Object* element = shared_info_array->GetElementNoExceptionThrown(i); | 1625 Object* element = shared_info_array->GetElementNoExceptionThrown(i); |
1612 CHECK(element->IsJSValue()); | 1626 CHECK(element->IsJSValue()); |
1613 Handle<JSValue> jsvalue(JSValue::cast(element)); | 1627 Handle<JSValue> jsvalue(JSValue::cast(element)); |
1614 Handle<SharedFunctionInfo> shared = | 1628 Handle<SharedFunctionInfo> shared = |
1615 UnwrapSharedFunctionInfoFromJSValue(jsvalue); | 1629 UnwrapSharedFunctionInfoFromJSValue(jsvalue); |
1616 | 1630 |
1617 if (function->shared() == *shared || IsInlined(*function, *shared)) { | 1631 if (function->shared() == *shared || IsInlined(*function, *shared)) { |
1618 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status))); | 1632 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status), |
1633 isolate)); | |
1619 return true; | 1634 return true; |
1620 } | 1635 } |
1621 } | 1636 } |
1622 return false; | 1637 return false; |
1623 } | 1638 } |
1624 | 1639 |
1625 | 1640 |
1626 // Iterates over handler chain and removes all elements that are inside | 1641 // Iterates over handler chain and removes all elements that are inside |
1627 // frames being dropped. | 1642 // frames being dropped. |
1628 static bool FixTryCatchHandler(StackFrame* top_frame, | 1643 static bool FixTryCatchHandler(StackFrame* top_frame, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1913 Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop, | 1928 Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop, |
1914 Zone* zone) { | 1929 Zone* zone) { |
1915 MultipleFunctionTarget target(shared_info_array, result); | 1930 MultipleFunctionTarget target(shared_info_array, result); |
1916 | 1931 |
1917 const char* message = | 1932 const char* message = |
1918 DropActivationsInActiveThreadImpl(target, do_drop, zone); | 1933 DropActivationsInActiveThreadImpl(target, do_drop, zone); |
1919 if (message) { | 1934 if (message) { |
1920 return message; | 1935 return message; |
1921 } | 1936 } |
1922 | 1937 |
1938 Isolate* isolate = shared_info_array->GetIsolate(); | |
1923 int array_len = GetArrayLength(shared_info_array); | 1939 int array_len = GetArrayLength(shared_info_array); |
1924 | 1940 |
1925 // Replace "blocked on active" with "replaced on active" status. | 1941 // Replace "blocked on active" with "replaced on active" status. |
1926 for (int i = 0; i < array_len; i++) { | 1942 for (int i = 0; i < array_len; i++) { |
1927 if (result->GetElement(i) == | 1943 if (result->GetElement(i) == |
1928 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { | 1944 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { |
1929 Handle<Object> replaced( | 1945 Handle<Object> replaced( |
1930 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK)); | 1946 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate); |
1931 SetElementNonStrict(result, i, replaced); | 1947 SetElementNonStrict(result, i, replaced); |
1932 } | 1948 } |
1933 } | 1949 } |
1934 return NULL; | 1950 return NULL; |
1935 } | 1951 } |
1936 | 1952 |
1937 | 1953 |
1938 class InactiveThreadActivationsChecker : public ThreadVisitor { | 1954 class InactiveThreadActivationsChecker : public ThreadVisitor { |
1939 public: | 1955 public: |
1940 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, | 1956 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, |
(...skipping 14 matching lines...) Expand all Loading... | |
1955 | 1971 |
1956 private: | 1972 private: |
1957 Handle<JSArray> shared_info_array_; | 1973 Handle<JSArray> shared_info_array_; |
1958 Handle<JSArray> result_; | 1974 Handle<JSArray> result_; |
1959 bool has_blocked_functions_; | 1975 bool has_blocked_functions_; |
1960 }; | 1976 }; |
1961 | 1977 |
1962 | 1978 |
1963 Handle<JSArray> LiveEdit::CheckAndDropActivations( | 1979 Handle<JSArray> LiveEdit::CheckAndDropActivations( |
1964 Handle<JSArray> shared_info_array, bool do_drop, Zone* zone) { | 1980 Handle<JSArray> shared_info_array, bool do_drop, Zone* zone) { |
1981 Isolate* isolate = shared_info_array->GetIsolate(); | |
1965 int len = GetArrayLength(shared_info_array); | 1982 int len = GetArrayLength(shared_info_array); |
1966 | 1983 |
1967 Handle<JSArray> result = FACTORY->NewJSArray(len); | 1984 Handle<JSArray> result = isolate->factory()->NewJSArray(len); |
1968 | 1985 |
1969 // Fill the default values. | 1986 // Fill the default values. |
1970 for (int i = 0; i < len; i++) { | 1987 for (int i = 0; i < len; i++) { |
1971 SetElementNonStrict( | 1988 SetElementNonStrict( |
1972 result, | 1989 result, |
1973 i, | 1990 i, |
1974 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH))); | 1991 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH), isolate)); |
1975 } | 1992 } |
1976 | 1993 |
1977 | 1994 |
1978 // First check inactive threads. Fail if some functions are blocked there. | 1995 // First check inactive threads. Fail if some functions are blocked there. |
1979 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 1996 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
1980 result); | 1997 result); |
1981 Isolate::Current()->thread_manager()->IterateArchivedThreads( | 1998 Isolate::Current()->thread_manager()->IterateArchivedThreads( |
1982 &inactive_threads_checker); | 1999 &inactive_threads_checker); |
1983 if (inactive_threads_checker.HasBlockedFunctions()) { | 2000 if (inactive_threads_checker.HasBlockedFunctions()) { |
1984 return result; | 2001 return result; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2102 | 2119 |
2103 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2120 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
2104 return false; | 2121 return false; |
2105 } | 2122 } |
2106 | 2123 |
2107 #endif // ENABLE_DEBUGGER_SUPPORT | 2124 #endif // ENABLE_DEBUGGER_SUPPORT |
2108 | 2125 |
2109 | 2126 |
2110 | 2127 |
2111 } } // namespace v8::internal | 2128 } } // namespace v8::internal |
OLD | NEW |