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

Side by Side Diff: src/objects.cc

Issue 293223002: Avoid dynamic initial map check when inlining call-new. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "allocation-site-scopes.h" 8 #include "allocation-site-scopes.h"
9 #include "api.h" 9 #include "api.h"
10 #include "arguments.h" 10 #include "arguments.h"
(...skipping 10192 matching lines...) Expand 10 before | Expand all | Expand 10 after
10203 maps->set(next_kind, *new_map); 10203 maps->set(next_kind, *new_map);
10204 current_map = new_map; 10204 current_map = new_map;
10205 } 10205 }
10206 native_context->set_js_array_maps(*maps); 10206 native_context->set_js_array_maps(*maps);
10207 return initial_map; 10207 return initial_map;
10208 } 10208 }
10209 10209
10210 10210
10211 void JSFunction::SetInstancePrototype(Handle<JSFunction> function, 10211 void JSFunction::SetInstancePrototype(Handle<JSFunction> function,
10212 Handle<Object> value) { 10212 Handle<Object> value) {
10213 Isolate* isolate = function->GetIsolate();
10214
10213 ASSERT(value->IsJSReceiver()); 10215 ASSERT(value->IsJSReceiver());
10214 10216
10215 // First some logic for the map of the prototype to make sure it is in fast 10217 // First some logic for the map of the prototype to make sure it is in fast
10216 // mode. 10218 // mode.
10217 if (value->IsJSObject()) { 10219 if (value->IsJSObject()) {
10218 JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value)); 10220 JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value));
10219 } 10221 }
10220 10222
10221 // Now some logic for the maps of the objects that are created by using this 10223 // Now some logic for the maps of the objects that are created by using this
10222 // function as a constructor. 10224 // function as a constructor.
10223 if (function->has_initial_map()) { 10225 if (function->has_initial_map()) {
10224 // If the function has allocated the initial map replace it with a 10226 // If the function has allocated the initial map replace it with a
10225 // copy containing the new prototype. Also complete any in-object 10227 // copy containing the new prototype. Also complete any in-object
10226 // slack tracking that is in progress at this point because it is 10228 // slack tracking that is in progress at this point because it is
10227 // still tracking the old copy. 10229 // still tracking the old copy.
10228 if (function->shared()->IsInobjectSlackTrackingInProgress()) { 10230 if (function->shared()->IsInobjectSlackTrackingInProgress()) {
10229 function->shared()->CompleteInobjectSlackTracking(); 10231 function->shared()->CompleteInobjectSlackTracking();
10230 } 10232 }
10231 Handle<Map> new_map = Map::Copy(handle(function->initial_map())); 10233 Handle<Map> initial_map(function->initial_map(), isolate);
10234 Handle<Map> new_map = Map::Copy(initial_map);
10232 new_map->set_prototype(*value); 10235 new_map->set_prototype(*value);
10233 10236
10234 // If the function is used as the global Array function, cache the 10237 // If the function is used as the global Array function, cache the
10235 // initial map (and transitioned versions) in the native context. 10238 // initial map (and transitioned versions) in the native context.
10236 Context* native_context = function->context()->native_context(); 10239 Context* native_context = function->context()->native_context();
10237 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX); 10240 Object* array_function = native_context->get(Context::ARRAY_FUNCTION_INDEX);
10238 if (array_function->IsJSFunction() && 10241 if (array_function->IsJSFunction() &&
10239 *function == JSFunction::cast(array_function)) { 10242 *function == JSFunction::cast(array_function)) {
10240 CacheInitialJSArrayMaps(handle(native_context), new_map); 10243 CacheInitialJSArrayMaps(handle(native_context, isolate), new_map);
10241 } 10244 }
10242 10245
10243 function->set_initial_map(*new_map); 10246 function->set_initial_map(*new_map);
10247
10248 // Deoptimize all code that embeds the previous initial map.
10249 initial_map->dependent_code()->DeoptimizeDependentCodeGroup(
10250 isolate, DependentCode::kInitialMapChangedGroup);
10244 } else { 10251 } else {
10245 // Put the value in the initial map field until an initial map is 10252 // Put the value in the initial map field until an initial map is
10246 // needed. At that point, a new initial map is created and the 10253 // needed. At that point, a new initial map is created and the
10247 // prototype is put into the initial map where it belongs. 10254 // prototype is put into the initial map where it belongs.
10248 function->set_prototype_or_initial_map(*value); 10255 function->set_prototype_or_initial_map(*value);
10249 } 10256 }
10250 function->GetHeap()->ClearInstanceofCache(); 10257 isolate->heap()->ClearInstanceofCache();
10251 } 10258 }
10252 10259
10253 10260
10254 void JSFunction::SetPrototype(Handle<JSFunction> function, 10261 void JSFunction::SetPrototype(Handle<JSFunction> function,
10255 Handle<Object> value) { 10262 Handle<Object> value) {
10256 ASSERT(function->should_have_prototype()); 10263 ASSERT(function->should_have_prototype());
10257 Handle<Object> construct_prototype = value; 10264 Handle<Object> construct_prototype = value;
10258 10265
10259 // If the value is not a JSReceiver, store the value in the map's 10266 // If the value is not a JSReceiver, store the value in the map's
10260 // constructor field so it can be accessed. Also, set the prototype 10267 // constructor field so it can be accessed. Also, set the prototype
(...skipping 7048 matching lines...) Expand 10 before | Expand all | Expand 10 after
17309 #define ERROR_MESSAGES_TEXTS(C, T) T, 17316 #define ERROR_MESSAGES_TEXTS(C, T) T,
17310 static const char* error_messages_[] = { 17317 static const char* error_messages_[] = {
17311 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17318 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17312 }; 17319 };
17313 #undef ERROR_MESSAGES_TEXTS 17320 #undef ERROR_MESSAGES_TEXTS
17314 return error_messages_[reason]; 17321 return error_messages_[reason];
17315 } 17322 }
17316 17323
17317 17324
17318 } } // namespace v8::internal 17325 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698