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

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: Created 5 years, 10 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') | src/objects.h » ('J')
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()); 1013 Handle<FixedArray> old_literals(fun->literals());
Michael Starzinger 2015/02/25 21:32:33 nit: The old_literals handle seems to be unused.
Toon Verwaest 2015/02/25 21:57:47 Done.
1017 Handle<FixedArray> new_literals = 1014 Handle<FixedArray> new_literals =
1018 isolate->factory()->NewFixedArray(new_literal_count); 1015 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); 1016 fun->set_literals(*new_literals);
1032 } 1017 }
1033 1018
1034 shared_info->set_num_literals(new_literal_count); 1019 shared_info->set_num_literals(new_literal_count);
1035 } 1020 }
1036 } 1021 }
1037 1022
1038 private: 1023 private:
1039 // Iterates all function instances in the HEAP that refers to the 1024 // Iterates all function instances in the HEAP that refers to the
1040 // provided shared_info. 1025 // provided shared_info.
(...skipping 27 matching lines...) Expand all
1068 IterateJSFunctions(shared_info, &collect_visitor); 1053 IterateJSFunctions(shared_info, &collect_visitor);
1069 } 1054 }
1070 return result; 1055 return result;
1071 } 1056 }
1072 1057
1073 class ClearValuesVisitor { 1058 class ClearValuesVisitor {
1074 public: 1059 public:
1075 void visit(JSFunction* fun) { 1060 void visit(JSFunction* fun) {
1076 FixedArray* literals = fun->literals(); 1061 FixedArray* literals = fun->literals();
1077 int len = literals->length(); 1062 int len = literals->length();
1078 for (int j = JSFunction::kLiteralsPrefixSize; j < len; j++) { 1063 for (int j = 0; j < len; j++) {
1079 literals->set_undefined(j); 1064 literals->set_undefined(j);
1080 } 1065 }
1081 } 1066 }
1082 }; 1067 };
1083 1068
1084 class CountVisitor { 1069 class CountVisitor {
1085 public: 1070 public:
1086 void visit(JSFunction* fun) { 1071 void visit(JSFunction* fun) {
1087 count++; 1072 count++;
1088 } 1073 }
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { 2055 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
2071 isolate_->active_function_info_listener()->FunctionCode(code); 2056 isolate_->active_function_info_listener()->FunctionCode(code);
2072 } 2057 }
2073 2058
2074 2059
2075 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { 2060 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
2076 return isolate->active_function_info_listener() != NULL; 2061 return isolate->active_function_info_listener() != NULL;
2077 } 2062 }
2078 2063
2079 } } // namespace v8::internal 2064 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698