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

Side by Side Diff: src/liveedit.cc

Issue 952303002: Remove NativeContext from Literal array, since we always create the literals in the native context … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 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
« no previous file with comments | « src/factory.cc ('k') | src/objects.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 // 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 5
6 #include "src/v8.h" 6 #include "src/v8.h"
7 7
8 #include "src/liveedit.h" 8 #include "src/liveedit.h"
9 9
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 // Name 'literals' is a misnomer. Rather it's a cache for complex object 988 // Name 'literals' is a misnomer. Rather it's a cache for complex object
989 // boilerplates and for a native context. We must clean cached values. 989 // boilerplates and for a native context. We must clean cached values.
990 // Additionally we may need to allocate a new array if number of literals 990 // Additionally we may need to allocate a new array if number of literals
991 // changed. 991 // changed.
992 class LiteralFixer { 992 class LiteralFixer {
993 public: 993 public:
994 static void PatchLiterals(FunctionInfoWrapper* compile_info_wrapper, 994 static void PatchLiterals(FunctionInfoWrapper* compile_info_wrapper,
995 Handle<SharedFunctionInfo> shared_info, 995 Handle<SharedFunctionInfo> shared_info,
996 Isolate* isolate) { 996 Isolate* isolate) {
997 int new_literal_count = compile_info_wrapper->GetLiteralCount(); 997 int new_literal_count = compile_info_wrapper->GetLiteralCount();
998 if (new_literal_count > 0) {
999 new_literal_count += JSFunction::kLiteralsPrefixSize;
1000 }
1001 int old_literal_count = shared_info->num_literals(); 998 int old_literal_count = shared_info->num_literals();
1002 999
1003 if (old_literal_count == new_literal_count) { 1000 if (old_literal_count == new_literal_count) {
1004 // If literal count didn't change, simply go over all functions 1001 // If literal count didn't change, simply go over all functions
1005 // and clear literal arrays. 1002 // and clear literal arrays.
1006 ClearValuesVisitor visitor; 1003 ClearValuesVisitor visitor;
1007 IterateJSFunctions(shared_info, &visitor); 1004 IterateJSFunctions(shared_info, &visitor);
1008 } else { 1005 } else {
1009 // When literal count changes, we have to create new array instances. 1006 // When literal count changes, we have to create new array instances.
1010 // Since we cannot create instances when iterating heap, we should first 1007 // Since we cannot create instances when iterating heap, we should first
1011 // collect all functions and fix their literal arrays. 1008 // collect all functions and fix their literal arrays.
1012 Handle<FixedArray> function_instances = 1009 Handle<FixedArray> function_instances =
1013 CollectJSFunctions(shared_info, isolate); 1010 CollectJSFunctions(shared_info, isolate);
1014 for (int i = 0; i < function_instances->length(); i++) { 1011 for (int i = 0; i < function_instances->length(); i++) {
1015 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i))); 1012 Handle<JSFunction> fun(JSFunction::cast(function_instances->get(i)));
1016 Handle<FixedArray> old_literals(fun->literals());
1017 Handle<FixedArray> new_literals = 1013 Handle<FixedArray> new_literals =
1018 isolate->factory()->NewFixedArray(new_literal_count); 1014 isolate->factory()->NewFixedArray(new_literal_count);
1019 if (new_literal_count > 0) {
1020 Handle<Context> native_context;
1021 if (old_literals->length() >
1022 JSFunction::kLiteralNativeContextIndex) {
1023 native_context = Handle<Context>(
1024 JSFunction::NativeContextFromLiterals(fun->literals()));
1025 } else {
1026 native_context = Handle<Context>(fun->context()->native_context());
1027 }
1028 new_literals->set(JSFunction::kLiteralNativeContextIndex,
1029 *native_context);
1030 }
1031 fun->set_literals(*new_literals); 1015 fun->set_literals(*new_literals);
1032 } 1016 }
1033 1017
1034 shared_info->set_num_literals(new_literal_count); 1018 shared_info->set_num_literals(new_literal_count);
1035 } 1019 }
1036 } 1020 }
1037 1021
1038 private: 1022 private:
1039 // Iterates all function instances in the HEAP that refers to the 1023 // Iterates all function instances in the HEAP that refers to the
1040 // provided shared_info. 1024 // provided shared_info.
(...skipping 27 matching lines...) Expand all
1068 IterateJSFunctions(shared_info, &collect_visitor); 1052 IterateJSFunctions(shared_info, &collect_visitor);
1069 } 1053 }
1070 return result; 1054 return result;
1071 } 1055 }
1072 1056
1073 class ClearValuesVisitor { 1057 class ClearValuesVisitor {
1074 public: 1058 public:
1075 void visit(JSFunction* fun) { 1059 void visit(JSFunction* fun) {
1076 FixedArray* literals = fun->literals(); 1060 FixedArray* literals = fun->literals();
1077 int len = literals->length(); 1061 int len = literals->length();
1078 for (int j = JSFunction::kLiteralsPrefixSize; j < len; j++) { 1062 for (int j = 0; j < len; j++) {
1079 literals->set_undefined(j); 1063 literals->set_undefined(j);
1080 } 1064 }
1081 } 1065 }
1082 }; 1066 };
1083 1067
1084 class CountVisitor { 1068 class CountVisitor {
1085 public: 1069 public:
1086 void visit(JSFunction* fun) { 1070 void visit(JSFunction* fun) {
1087 count++; 1071 count++;
1088 } 1072 }
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { 2054 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
2071 isolate_->active_function_info_listener()->FunctionCode(code); 2055 isolate_->active_function_info_listener()->FunctionCode(code);
2072 } 2056 }
2073 2057
2074 2058
2075 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2059 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2076 return isolate->active_function_info_listener() != NULL; 2060 return isolate->active_function_info_listener() != NULL;
2077 } 2061 }
2078 2062
2079 } } // namespace v8::internal 2063 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698