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

Side by Side Diff: src/liveedit.cc

Issue 177683002: Mode clean-up pt 1: rename classic/non-strict mode to sloppy mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "scopes.h" 42 #include "scopes.h"
43 #include "v8memory.h" 43 #include "v8memory.h"
44 44
45 namespace v8 { 45 namespace v8 {
46 namespace internal { 46 namespace internal {
47 47
48 48
49 #ifdef ENABLE_DEBUGGER_SUPPORT 49 #ifdef ENABLE_DEBUGGER_SUPPORT
50 50
51 51
52 void SetElementNonStrict(Handle<JSObject> object, 52 void SetElementSloppy(Handle<JSObject> object,
53 uint32_t index, 53 uint32_t index,
54 Handle<Object> value) { 54 Handle<Object> value) {
55 // Ignore return value from SetElement. It can only be a failure if there 55 // Ignore return value from SetElement. It can only be a failure if there
56 // are element setters causing exceptions and the debugger context has none 56 // are element setters causing exceptions and the debugger context has none
57 // of these. 57 // of these.
58 Handle<Object> no_failure = 58 Handle<Object> no_failure =
59 JSObject::SetElement(object, index, value, NONE, kNonStrictMode); 59 JSObject::SetElement(object, index, value, NONE, kSloppyMode);
60 ASSERT(!no_failure.is_null()); 60 ASSERT(!no_failure.is_null());
61 USE(no_failure); 61 USE(no_failure);
62 } 62 }
63 63
64 64
65 // A simple implementation of dynamic programming algorithm. It solves 65 // A simple implementation of dynamic programming algorithm. It solves
66 // the problem of finding the difference of 2 arrays. It uses a table of results 66 // the problem of finding the difference of 2 arrays. It uses a table of results
67 // of subproblems. Each cell contains a number together with 2-bit flag 67 // of subproblems. Each cell contains a number together with 2-bit flag
68 // that helps building the chunk list. 68 // that helps building the chunk list.
69 class Differencer { 69 class Differencer {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 public: 352 public:
353 explicit CompareOutputArrayWriter(Isolate* isolate) 353 explicit CompareOutputArrayWriter(Isolate* isolate)
354 : array_(isolate->factory()->NewJSArray(10)), current_size_(0) {} 354 : array_(isolate->factory()->NewJSArray(10)), current_size_(0) {}
355 355
356 Handle<JSArray> GetResult() { 356 Handle<JSArray> GetResult() {
357 return array_; 357 return array_;
358 } 358 }
359 359
360 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) { 360 void WriteChunk(int char_pos1, int char_pos2, int char_len1, int char_len2) {
361 Isolate* isolate = array_->GetIsolate(); 361 Isolate* isolate = array_->GetIsolate();
362 SetElementNonStrict(array_, 362 SetElementSloppy(array_,
363 current_size_, 363 current_size_,
364 Handle<Object>(Smi::FromInt(char_pos1), isolate)); 364 Handle<Object>(Smi::FromInt(char_pos1), isolate));
365 SetElementNonStrict(array_, 365 SetElementSloppy(array_,
366 current_size_ + 1, 366 current_size_ + 1,
367 Handle<Object>(Smi::FromInt(char_pos1 + char_len1), 367 Handle<Object>(Smi::FromInt(char_pos1 + char_len1),
368 isolate)); 368 isolate));
369 SetElementNonStrict(array_, 369 SetElementSloppy(array_,
370 current_size_ + 2, 370 current_size_ + 2,
371 Handle<Object>(Smi::FromInt(char_pos2 + char_len2), 371 Handle<Object>(Smi::FromInt(char_pos2 + char_len2),
372 isolate)); 372 isolate));
373 current_size_ += 3; 373 current_size_ += 3;
374 } 374 }
375 375
376 private: 376 private:
377 Handle<JSArray> array_; 377 Handle<JSArray> array_;
378 int current_size_; 378 int current_size_;
379 }; 379 };
380 380
381 381
382 // Represents 2 strings as 2 arrays of tokens. 382 // Represents 2 strings as 2 arrays of tokens.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 655 }
656 Handle<JSArray> GetJSArray() { 656 Handle<JSArray> GetJSArray() {
657 return array_; 657 return array_;
658 } 658 }
659 Isolate* isolate() const { 659 Isolate* isolate() const {
660 return array_->GetIsolate(); 660 return array_->GetIsolate();
661 } 661 }
662 662
663 protected: 663 protected:
664 void SetField(int field_position, Handle<Object> value) { 664 void SetField(int field_position, Handle<Object> value) {
665 SetElementNonStrict(array_, field_position, value); 665 SetElementSloppy(array_, field_position, value);
666 } 666 }
667 void SetSmiValueField(int field_position, int value) { 667 void SetSmiValueField(int field_position, int value) {
668 SetElementNonStrict(array_, 668 SetElementSloppy(array_,
669 field_position, 669 field_position,
670 Handle<Smi>(Smi::FromInt(value), isolate())); 670 Handle<Smi>(Smi::FromInt(value), isolate()));
671 } 671 }
672 Object* GetField(int field_position) { 672 Object* GetField(int field_position) {
673 return array_->GetElementNoExceptionThrown(isolate(), field_position); 673 return array_->GetElementNoExceptionThrown(isolate(), field_position);
674 } 674 }
675 int GetSmiValueField(int field_position) { 675 int GetSmiValueField(int field_position) {
676 Object* res = GetField(field_position); 676 Object* res = GetField(field_position);
677 CHECK(res->IsSmi()); 677 CHECK(res->IsSmi());
678 return Smi::cast(res)->value(); 678 return Smi::cast(res)->value();
679 } 679 }
680 680
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 811 }
812 812
813 void FunctionStarted(FunctionLiteral* fun) { 813 void FunctionStarted(FunctionLiteral* fun) {
814 HandleScope scope(isolate()); 814 HandleScope scope(isolate());
815 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); 815 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate());
816 info.SetInitialProperties(fun->name(), fun->start_position(), 816 info.SetInitialProperties(fun->name(), fun->start_position(),
817 fun->end_position(), fun->parameter_count(), 817 fun->end_position(), fun->parameter_count(),
818 fun->materialized_literal_count(), 818 fun->materialized_literal_count(),
819 current_parent_index_); 819 current_parent_index_);
820 current_parent_index_ = len_; 820 current_parent_index_ = len_;
821 SetElementNonStrict(result_, len_, info.GetJSArray()); 821 SetElementSloppy(result_, len_, info.GetJSArray());
822 len_++; 822 len_++;
823 } 823 }
824 824
825 void FunctionDone() { 825 void FunctionDone() {
826 HandleScope scope(isolate()); 826 HandleScope scope(isolate());
827 FunctionInfoWrapper info = 827 FunctionInfoWrapper info =
828 FunctionInfoWrapper::cast( 828 FunctionInfoWrapper::cast(
829 result_->GetElementNoExceptionThrown( 829 result_->GetElementNoExceptionThrown(
830 isolate(), current_parent_index_)); 830 isolate(), current_parent_index_));
831 current_parent_index_ = info.GetParentIndex(); 831 current_parent_index_ = info.GetParentIndex();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // scopes of this chain. 878 // scopes of this chain.
879 Scope* current_scope = scope; 879 Scope* current_scope = scope;
880 while (current_scope != NULL) { 880 while (current_scope != NULL) {
881 ZoneList<Variable*> stack_list(current_scope->StackLocalCount(), zone); 881 ZoneList<Variable*> stack_list(current_scope->StackLocalCount(), zone);
882 ZoneList<Variable*> context_list( 882 ZoneList<Variable*> context_list(
883 current_scope->ContextLocalCount(), zone); 883 current_scope->ContextLocalCount(), zone);
884 current_scope->CollectStackAndContextLocals(&stack_list, &context_list); 884 current_scope->CollectStackAndContextLocals(&stack_list, &context_list);
885 context_list.Sort(&Variable::CompareIndex); 885 context_list.Sort(&Variable::CompareIndex);
886 886
887 for (int i = 0; i < context_list.length(); i++) { 887 for (int i = 0; i < context_list.length(); i++) {
888 SetElementNonStrict(scope_info_list, 888 SetElementSloppy(scope_info_list,
889 scope_info_length, 889 scope_info_length,
890 context_list[i]->name()); 890 context_list[i]->name());
891 scope_info_length++; 891 scope_info_length++;
892 SetElementNonStrict( 892 SetElementSloppy(
893 scope_info_list, 893 scope_info_list,
894 scope_info_length, 894 scope_info_length,
895 Handle<Smi>(Smi::FromInt(context_list[i]->index()), isolate())); 895 Handle<Smi>(Smi::FromInt(context_list[i]->index()), isolate()));
896 scope_info_length++; 896 scope_info_length++;
897 } 897 }
898 SetElementNonStrict(scope_info_list, 898 SetElementSloppy(scope_info_list,
899 scope_info_length, 899 scope_info_length,
900 Handle<Object>(isolate()->heap()->null_value(), 900 Handle<Object>(isolate()->heap()->null_value(),
901 isolate())); 901 isolate()));
902 scope_info_length++; 902 scope_info_length++;
903 903
904 current_scope = current_scope->outer_scope(); 904 current_scope = current_scope->outer_scope();
905 } 905 }
906 906
907 return *scope_info_list; 907 return *scope_info_list;
908 } 908 }
909 909
910 Handle<JSArray> result_; 910 Handle<JSArray> result_;
911 int len_; 911 int len_;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 STATIC_ASCII_VECTOR("startPosition")); 952 STATIC_ASCII_VECTOR("startPosition"));
953 Handle<String> end_pos_key = factory->InternalizeOneByteString( 953 Handle<String> end_pos_key = factory->InternalizeOneByteString(
954 STATIC_ASCII_VECTOR("endPosition")); 954 STATIC_ASCII_VECTOR("endPosition"));
955 Handle<String> script_obj_key = factory->InternalizeOneByteString( 955 Handle<String> script_obj_key = factory->InternalizeOneByteString(
956 STATIC_ASCII_VECTOR("scriptObject")); 956 STATIC_ASCII_VECTOR("scriptObject"));
957 Handle<Smi> start_pos( 957 Handle<Smi> start_pos(
958 Smi::FromInt(message_location.start_pos()), isolate); 958 Smi::FromInt(message_location.start_pos()), isolate);
959 Handle<Smi> end_pos(Smi::FromInt(message_location.end_pos()), isolate); 959 Handle<Smi> end_pos(Smi::FromInt(message_location.end_pos()), isolate);
960 Handle<JSValue> script_obj = GetScriptWrapper(message_location.script()); 960 Handle<JSValue> script_obj = GetScriptWrapper(message_location.script());
961 JSReceiver::SetProperty( 961 JSReceiver::SetProperty(
962 rethrow_exception, start_pos_key, start_pos, NONE, kNonStrictMode); 962 rethrow_exception, start_pos_key, start_pos, NONE, kSloppyMode);
963 JSReceiver::SetProperty( 963 JSReceiver::SetProperty(
964 rethrow_exception, end_pos_key, end_pos, NONE, kNonStrictMode); 964 rethrow_exception, end_pos_key, end_pos, NONE, kSloppyMode);
965 JSReceiver::SetProperty( 965 JSReceiver::SetProperty(
966 rethrow_exception, script_obj_key, script_obj, NONE, kNonStrictMode); 966 rethrow_exception, script_obj_key, script_obj, NONE, kSloppyMode);
967 } 967 }
968 } 968 }
969 969
970 // A logical 'finally' section. 970 // A logical 'finally' section.
971 isolate->set_active_function_info_listener(NULL); 971 isolate->set_active_function_info_listener(NULL);
972 script->set_source(*original_source); 972 script->set_source(*original_source);
973 973
974 if (rethrow_exception.is_null()) { 974 if (rethrow_exception.is_null()) {
975 return *(listener.GetResult()); 975 return *(listener.GetResult());
976 } else { 976 } else {
977 isolate->Throw(*rethrow_exception); 977 isolate->Throw(*rethrow_exception);
978 return 0; 978 return 0;
979 } 979 }
980 } 980 }
981 981
982 982
983 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { 983 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
984 Isolate* isolate = array->GetIsolate(); 984 Isolate* isolate = array->GetIsolate();
985 HandleScope scope(isolate); 985 HandleScope scope(isolate);
986 int len = GetArrayLength(array); 986 int len = GetArrayLength(array);
987 for (int i = 0; i < len; i++) { 987 for (int i = 0; i < len; i++) {
988 Handle<SharedFunctionInfo> info( 988 Handle<SharedFunctionInfo> info(
989 SharedFunctionInfo::cast( 989 SharedFunctionInfo::cast(
990 array->GetElementNoExceptionThrown(isolate, i))); 990 array->GetElementNoExceptionThrown(isolate, i)));
991 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate); 991 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate);
992 Handle<String> name_handle(String::cast(info->name())); 992 Handle<String> name_handle(String::cast(info->name()));
993 info_wrapper.SetProperties(name_handle, info->start_position(), 993 info_wrapper.SetProperties(name_handle, info->start_position(),
994 info->end_position(), info); 994 info->end_position(), info);
995 SetElementNonStrict(array, i, info_wrapper.GetJSArray()); 995 SetElementSloppy(array, i, info_wrapper.GetJSArray());
996 } 996 }
997 } 997 }
998 998
999 999
1000 // Visitor that finds all references to a particular code object, 1000 // Visitor that finds all references to a particular code object,
1001 // including "CODE_TARGET" references in other code objects and replaces 1001 // including "CODE_TARGET" references in other code objects and replaces
1002 // them on the fly. 1002 // them on the fly.
1003 class ReplacingVisitor : public ObjectVisitor { 1003 class ReplacingVisitor : public ObjectVisitor {
1004 public: 1004 public:
1005 explicit ReplacingVisitor(Code* original, Code* substitution) 1005 explicit ReplacingVisitor(Code* original, Code* substitution)
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 int len = GetArrayLength(shared_info_array); 1633 int len = GetArrayLength(shared_info_array);
1634 for (int i = 0; i < len; i++) { 1634 for (int i = 0; i < len; i++) {
1635 Object* element = 1635 Object* element =
1636 shared_info_array->GetElementNoExceptionThrown(isolate, i); 1636 shared_info_array->GetElementNoExceptionThrown(isolate, i);
1637 CHECK(element->IsJSValue()); 1637 CHECK(element->IsJSValue());
1638 Handle<JSValue> jsvalue(JSValue::cast(element)); 1638 Handle<JSValue> jsvalue(JSValue::cast(element));
1639 Handle<SharedFunctionInfo> shared = 1639 Handle<SharedFunctionInfo> shared =
1640 UnwrapSharedFunctionInfoFromJSValue(jsvalue); 1640 UnwrapSharedFunctionInfoFromJSValue(jsvalue);
1641 1641
1642 if (function->shared() == *shared || IsInlined(*function, *shared)) { 1642 if (function->shared() == *shared || IsInlined(*function, *shared)) {
1643 SetElementNonStrict(result, i, Handle<Smi>(Smi::FromInt(status), 1643 SetElementSloppy(result, i, Handle<Smi>(Smi::FromInt(status), isolate));
1644 isolate));
1645 return true; 1644 return true;
1646 } 1645 }
1647 } 1646 }
1648 return false; 1647 return false;
1649 } 1648 }
1650 1649
1651 1650
1652 // Iterates over handler chain and removes all elements that are inside 1651 // Iterates over handler chain and removes all elements that are inside
1653 // frames being dropped. 1652 // frames being dropped.
1654 static bool FixTryCatchHandler(StackFrame* top_frame, 1653 static bool FixTryCatchHandler(StackFrame* top_frame,
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 1947
1949 Isolate* isolate = shared_info_array->GetIsolate(); 1948 Isolate* isolate = shared_info_array->GetIsolate();
1950 int array_len = GetArrayLength(shared_info_array); 1949 int array_len = GetArrayLength(shared_info_array);
1951 1950
1952 // Replace "blocked on active" with "replaced on active" status. 1951 // Replace "blocked on active" with "replaced on active" status.
1953 for (int i = 0; i < array_len; i++) { 1952 for (int i = 0; i < array_len; i++) {
1954 if (result->GetElement(result->GetIsolate(), i) == 1953 if (result->GetElement(result->GetIsolate(), i) ==
1955 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) { 1954 Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
1956 Handle<Object> replaced( 1955 Handle<Object> replaced(
1957 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate); 1956 Smi::FromInt(LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK), isolate);
1958 SetElementNonStrict(result, i, replaced); 1957 SetElementSloppy(result, i, replaced);
1959 } 1958 }
1960 } 1959 }
1961 return NULL; 1960 return NULL;
1962 } 1961 }
1963 1962
1964 1963
1965 class InactiveThreadActivationsChecker : public ThreadVisitor { 1964 class InactiveThreadActivationsChecker : public ThreadVisitor {
1966 public: 1965 public:
1967 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array, 1966 InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array,
1968 Handle<JSArray> result) 1967 Handle<JSArray> result)
(...skipping 20 matching lines...) Expand all
1989 1988
1990 Handle<JSArray> LiveEdit::CheckAndDropActivations( 1989 Handle<JSArray> LiveEdit::CheckAndDropActivations(
1991 Handle<JSArray> shared_info_array, bool do_drop) { 1990 Handle<JSArray> shared_info_array, bool do_drop) {
1992 Isolate* isolate = shared_info_array->GetIsolate(); 1991 Isolate* isolate = shared_info_array->GetIsolate();
1993 int len = GetArrayLength(shared_info_array); 1992 int len = GetArrayLength(shared_info_array);
1994 1993
1995 Handle<JSArray> result = isolate->factory()->NewJSArray(len); 1994 Handle<JSArray> result = isolate->factory()->NewJSArray(len);
1996 1995
1997 // Fill the default values. 1996 // Fill the default values.
1998 for (int i = 0; i < len; i++) { 1997 for (int i = 0; i < len; i++) {
1999 SetElementNonStrict( 1998 SetElementSloppy(
2000 result, 1999 result,
2001 i, 2000 i,
2002 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH), isolate)); 2001 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH), isolate));
2003 } 2002 }
2004 2003
2005 2004
2006 // First check inactive threads. Fail if some functions are blocked there. 2005 // First check inactive threads. Fail if some functions are blocked there.
2007 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, 2006 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array,
2008 result); 2007 result);
2009 isolate->thread_manager()->IterateArchivedThreads( 2008 isolate->thread_manager()->IterateArchivedThreads(
2010 &inactive_threads_checker); 2009 &inactive_threads_checker);
2011 if (inactive_threads_checker.HasBlockedFunctions()) { 2010 if (inactive_threads_checker.HasBlockedFunctions()) {
2012 return result; 2011 return result;
2013 } 2012 }
2014 2013
2015 // Try to drop activations from the current stack. 2014 // Try to drop activations from the current stack.
2016 const char* error_message = 2015 const char* error_message =
2017 DropActivationsInActiveThread(shared_info_array, result, do_drop); 2016 DropActivationsInActiveThread(shared_info_array, result, do_drop);
2018 if (error_message != NULL) { 2017 if (error_message != NULL) {
2019 // Add error message as an array extra element. 2018 // Add error message as an array extra element.
2020 Vector<const char> vector_message(error_message, StrLength(error_message)); 2019 Vector<const char> vector_message(error_message, StrLength(error_message));
2021 Handle<String> str = isolate->factory()->NewStringFromAscii(vector_message); 2020 Handle<String> str = isolate->factory()->NewStringFromAscii(vector_message);
2022 SetElementNonStrict(result, len, str); 2021 SetElementSloppy(result, len, str);
2023 } 2022 }
2024 return result; 2023 return result;
2025 } 2024 }
2026 2025
2027 2026
2028 // Describes a single callframe a target. Not finding this frame 2027 // Describes a single callframe a target. Not finding this frame
2029 // means an error. 2028 // means an error.
2030 class SingleFrameTarget { 2029 class SingleFrameTarget {
2031 public: 2030 public:
2032 explicit SingleFrameTarget(JavaScriptFrame* frame) 2031 explicit SingleFrameTarget(JavaScriptFrame* frame)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 2130
2132 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2131 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2133 return false; 2132 return false;
2134 } 2133 }
2135 2134
2136 #endif // ENABLE_DEBUGGER_SUPPORT 2135 #endif // ENABLE_DEBUGGER_SUPPORT
2137 2136
2138 2137
2139 2138
2140 } } // namespace v8::internal 2139 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698