Index: src/runtime.cc |
=================================================================== |
--- src/runtime.cc (revision 5500) |
+++ src/runtime.cc (working copy) |
@@ -6279,7 +6279,7 @@ |
} |
-static Code* ComputeConstructStub(Handle<JSFunction> function) { |
+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/
|
Handle<Object> prototype = Factory::null_value(); |
if (function->has_instance_prototype()) { |
prototype = Handle<Object>(function->instance_prototype()); |
@@ -6287,13 +6287,10 @@ |
if (function->shared()->CanGenerateInlineConstructor(*prototype)) { |
ConstructStubCompiler compiler; |
Object* code = compiler.CompileConstructStub(function->shared()); |
- if (code->IsFailure()) { |
- return Builtins::builtin(Builtins::JSConstructStubGeneric); |
+ if (!code->IsFailure()) { |
+ function->shared()->set_construct_stub(Code::cast(code)); |
} |
- return Code::cast(code); |
} |
- |
- return function->shared()->construct_stub(); |
} |
@@ -6350,12 +6347,21 @@ |
Handle<SharedFunctionInfo> shared(function->shared()); |
EnsureCompiled(shared, CLEAR_EXCEPTION); |
- bool first_allocation = !function->has_initial_map(); |
+ if (!function->has_initial_map() && |
+ shared->IsInobjectSlackTrackingInProgress()) { |
+ // The tracking can be in progress only in some other context |
+ // (because in the current context the function has no initial_map). |
+ // We can only do the tracking in one context at a time, so we force the |
+ // completion before the current context starts allocating objects. |
+ shared->CompleteInobjectSlackTracking(); |
+ SetInlineConstructStub(function); |
+ } |
+ |
+ bool first_allocation = !shared->live_objects_may_exist(); |
Handle<JSObject> result = Factory::NewJSObject(function); |
- if (first_allocation) { |
- Handle<Code> stub = Handle<Code>( |
- ComputeConstructStub(Handle<JSFunction>(function))); |
- shared->set_construct_stub(*stub); |
+ // Delay setting the stub if inobject slack tracking is in progress. |
+ if (first_allocation && !shared->IsInobjectSlackTrackingInProgress()) { |
+ SetInlineConstructStub(function); |
} |
Counters::constructed_objects.Increment(); |
@@ -6365,6 +6371,31 @@ |
} |
+static Object* Runtime_FinalizeInstanceSize(Arguments args) { |
+ HandleScope scope; |
+ ASSERT(args.length() == 1); |
+ |
+ Handle<Object> constructor = args.at<Object>(0); |
+ |
+ // 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
|
+ if (!constructor->IsJSFunction()) { |
+ Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
+ Handle<Object> type_error = |
+ Factory::NewTypeError("not_constructor", arguments); |
+ return Top::Throw(*type_error); |
+ } |
+ |
+ Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
+ Handle<SharedFunctionInfo> shared(function->shared()); |
+ |
+ ASSERT(shared->IsInobjectSlackTrackingInProgress()); |
+ shared->CompleteInobjectSlackTracking(); |
+ SetInlineConstructStub(function); |
+ |
+ return Heap::undefined_value(); |
+} |
+ |
+ |
static Object* Runtime_LazyCompile(Arguments args) { |
HandleScope scope; |
ASSERT(args.length() == 1); |