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

Side by Side Diff: src/handles.cc

Issue 26955004: Refactor part of handles.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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/handles.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('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 // 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( 143 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
144 Handle<JSFunction> constructor, 144 Handle<JSFunction> constructor,
145 Handle<JSGlobalProxy> global) { 145 Handle<JSGlobalProxy> global) {
146 CALL_HEAP_FUNCTION( 146 CALL_HEAP_FUNCTION(
147 constructor->GetIsolate(), 147 constructor->GetIsolate(),
148 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global), 148 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global),
149 JSGlobalProxy); 149 JSGlobalProxy);
150 } 150 }
151 151
152 152
153 void SetExpectedNofProperties(Handle<JSFunction> func, int nof) {
154 // If objects constructed from this function exist then changing
155 // 'estimated_nof_properties' is dangerous since the previous value might
156 // have been compiled into the fast construct stub. More over, the inobject
157 // slack tracking logic might have adjusted the previous value, so even
158 // passing the same value is risky.
159 if (func->shared()->live_objects_may_exist()) return;
160
161 func->shared()->set_expected_nof_properties(nof);
162 if (func->has_initial_map()) {
163 Handle<Map> new_initial_map =
164 func->GetIsolate()->factory()->CopyMap(
165 Handle<Map>(func->initial_map()));
166 new_initial_map->set_unused_property_fields(nof);
167 func->set_initial_map(*new_initial_map);
168 }
169 }
170
171
172 static int ExpectedNofPropertiesFromEstimate(int estimate) {
173 // If no properties are added in the constructor, they are more likely
174 // to be added later.
175 if (estimate == 0) estimate = 2;
176
177 // We do not shrink objects that go into a snapshot (yet), so we adjust
178 // the estimate conservatively.
179 if (Serializer::enabled()) return estimate + 2;
180
181 // Inobject slack tracking will reclaim redundant inobject space later,
182 // so we can afford to adjust the estimate generously.
183 if (FLAG_clever_optimizations) {
184 return estimate + 8;
185 } else {
186 return estimate + 3;
187 }
188 }
189
190
191 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
192 int estimate) {
193 // See the comment in SetExpectedNofProperties.
194 if (shared->live_objects_may_exist()) return;
195
196 shared->set_expected_nof_properties(
197 ExpectedNofPropertiesFromEstimate(estimate));
198 }
199
200
201 void FlattenString(Handle<String> string) { 153 void FlattenString(Handle<String> string) {
202 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten()); 154 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten());
203 } 155 }
204 156
205 157
206 Handle<String> FlattenGetString(Handle<String> string) { 158 Handle<String> FlattenGetString(Handle<String> string) {
207 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String); 159 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String);
208 } 160 }
209 161
210 162
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 Handle<Code> code) { 838 Handle<Code> code) {
887 heap->EnsureWeakObjectToCodeTable(); 839 heap->EnsureWeakObjectToCodeTable();
888 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); 840 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
889 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); 841 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code);
890 CALL_HEAP_FUNCTION_VOID(heap->isolate(), 842 CALL_HEAP_FUNCTION_VOID(heap->isolate(),
891 heap->AddWeakObjectToCodeDependency(*object, *dep)); 843 heap->AddWeakObjectToCodeDependency(*object, *dep));
892 } 844 }
893 845
894 846
895 } } // namespace v8::internal 847 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698