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

Side by Side Diff: src/runtime.cc

Issue 3329019: Dynamically determine optimal instance size.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 6261 matching lines...) Expand 10 before | Expand all | Expand 10 after
6272 Handle<Object> result = Execution::New( 6272 Handle<Object> result = Execution::New(
6273 function, fixed_length, *param_data, &exception); 6273 function, fixed_length, *param_data, &exception);
6274 if (exception) { 6274 if (exception) {
6275 return Failure::Exception(); 6275 return Failure::Exception();
6276 } 6276 }
6277 ASSERT(!result.is_null()); 6277 ASSERT(!result.is_null());
6278 return *result; 6278 return *result;
6279 } 6279 }
6280 6280
6281 6281
6282 static Code* ComputeConstructStub(Handle<JSFunction> function) { 6282 static void SetInlineConstructStub(Handle<JSFunction> function) {
Vitaly Repeshko 2010/09/22 14:40:25 This name is misleading. It makes the reader think
Vladislav Kaznacheev 2010/09/23 08:38:16 renamed to TrySettingInlineConstructStub On 2010/
6283 Handle<Object> prototype = Factory::null_value(); 6283 Handle<Object> prototype = Factory::null_value();
6284 if (function->has_instance_prototype()) { 6284 if (function->has_instance_prototype()) {
6285 prototype = Handle<Object>(function->instance_prototype()); 6285 prototype = Handle<Object>(function->instance_prototype());
6286 } 6286 }
6287 if (function->shared()->CanGenerateInlineConstructor(*prototype)) { 6287 if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
6288 ConstructStubCompiler compiler; 6288 ConstructStubCompiler compiler;
6289 Object* code = compiler.CompileConstructStub(function->shared()); 6289 Object* code = compiler.CompileConstructStub(function->shared());
6290 if (code->IsFailure()) { 6290 if (!code->IsFailure()) {
6291 return Builtins::builtin(Builtins::JSConstructStubGeneric); 6291 function->shared()->set_construct_stub(Code::cast(code));
6292 } 6292 }
6293 return Code::cast(code);
6294 } 6293 }
6295
6296 return function->shared()->construct_stub();
6297 } 6294 }
6298 6295
6299 6296
6300 static Object* Runtime_NewObject(Arguments args) { 6297 static Object* Runtime_NewObject(Arguments args) {
6301 HandleScope scope; 6298 HandleScope scope;
6302 ASSERT(args.length() == 1); 6299 ASSERT(args.length() == 1);
6303 6300
6304 Handle<Object> constructor = args.at<Object>(0); 6301 Handle<Object> constructor = args.at<Object>(0);
6305 6302
6306 // If the constructor isn't a proper function we throw a type error. 6303 // If the constructor isn't a proper function we throw a type error.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6343 // reported the same way whether or not 'Function' is called 6340 // reported the same way whether or not 'Function' is called
6344 // using 'new'. 6341 // using 'new'.
6345 return Top::context()->global(); 6342 return Top::context()->global();
6346 } 6343 }
6347 } 6344 }
6348 6345
6349 // The function should be compiled for the optimization hints to be available. 6346 // The function should be compiled for the optimization hints to be available.
6350 Handle<SharedFunctionInfo> shared(function->shared()); 6347 Handle<SharedFunctionInfo> shared(function->shared());
6351 EnsureCompiled(shared, CLEAR_EXCEPTION); 6348 EnsureCompiled(shared, CLEAR_EXCEPTION);
6352 6349
6353 bool first_allocation = !function->has_initial_map(); 6350 if (!function->has_initial_map() &&
6351 shared->IsInobjectSlackTrackingInProgress()) {
6352 // The tracking can be in progress only in some other context
6353 // (because in the current context the function has no initial_map).
6354 // We can only do the tracking in one context at a time, so we force the
6355 // completion before the current context starts allocating objects.
6356 shared->CompleteInobjectSlackTracking();
6357 SetInlineConstructStub(function);
6358 }
6359
6360 bool first_allocation = !shared->live_objects_may_exist();
6354 Handle<JSObject> result = Factory::NewJSObject(function); 6361 Handle<JSObject> result = Factory::NewJSObject(function);
6355 if (first_allocation) { 6362 // Delay setting the stub if inobject slack tracking is in progress.
6356 Handle<Code> stub = Handle<Code>( 6363 if (first_allocation && !shared->IsInobjectSlackTrackingInProgress()) {
6357 ComputeConstructStub(Handle<JSFunction>(function))); 6364 SetInlineConstructStub(function);
6358 shared->set_construct_stub(*stub);
6359 } 6365 }
6360 6366
6361 Counters::constructed_objects.Increment(); 6367 Counters::constructed_objects.Increment();
6362 Counters::constructed_objects_runtime.Increment(); 6368 Counters::constructed_objects_runtime.Increment();
6363 6369
6364 return *result; 6370 return *result;
6365 } 6371 }
6366 6372
6367 6373
6374 static Object* Runtime_FinalizeInstanceSize(Arguments args) {
6375 HandleScope scope;
6376 ASSERT(args.length() == 1);
6377
6378 Handle<Object> constructor = args.at<Object>(0);
6379
6380 // If the constructor isn't a proper function we throw a type error.
Vitaly Repeshko 2010/09/22 14:40:25 Why do have to throw this specific error? Why can'
Vladislav Kaznacheev 2010/09/23 08:38:16 I got confused when fuzz natives test failed on th
6381 if (!constructor->IsJSFunction()) {
6382 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
6383 Handle<Object> type_error =
6384 Factory::NewTypeError("not_constructor", arguments);
6385 return Top::Throw(*type_error);
6386 }
6387
6388 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
6389 Handle<SharedFunctionInfo> shared(function->shared());
6390
6391 ASSERT(shared->IsInobjectSlackTrackingInProgress());
6392 shared->CompleteInobjectSlackTracking();
6393 SetInlineConstructStub(function);
6394
6395 return Heap::undefined_value();
6396 }
6397
6398
6368 static Object* Runtime_LazyCompile(Arguments args) { 6399 static Object* Runtime_LazyCompile(Arguments args) {
6369 HandleScope scope; 6400 HandleScope scope;
6370 ASSERT(args.length() == 1); 6401 ASSERT(args.length() == 1);
6371 6402
6372 Handle<JSFunction> function = args.at<JSFunction>(0); 6403 Handle<JSFunction> function = args.at<JSFunction>(0);
6373 #ifdef DEBUG 6404 #ifdef DEBUG
6374 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { 6405 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
6375 PrintF("[lazy: "); 6406 PrintF("[lazy: ");
6376 function->shared()->name()->Print(); 6407 function->shared()->name()->Print();
6377 PrintF("]\n"); 6408 PrintF("]\n");
(...skipping 3785 matching lines...) Expand 10 before | Expand all | Expand 10 after
10163 } else { 10194 } else {
10164 // Handle last resort GC and make sure to allow future allocations 10195 // Handle last resort GC and make sure to allow future allocations
10165 // to grow the heap without causing GCs (if possible). 10196 // to grow the heap without causing GCs (if possible).
10166 Counters::gc_last_resort_from_js.Increment(); 10197 Counters::gc_last_resort_from_js.Increment();
10167 Heap::CollectAllGarbage(false); 10198 Heap::CollectAllGarbage(false);
10168 } 10199 }
10169 } 10200 }
10170 10201
10171 10202
10172 } } // namespace v8::internal 10203 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/runtime.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698