Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 8192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8203 Execution::New(Handle<JSFunction>::cast(bound_function), | 8203 Execution::New(Handle<JSFunction>::cast(bound_function), |
| 8204 total_argc, param_data.get(), &exception); | 8204 total_argc, param_data.get(), &exception); |
| 8205 if (exception) { | 8205 if (exception) { |
| 8206 return Failure::Exception(); | 8206 return Failure::Exception(); |
| 8207 } | 8207 } |
| 8208 ASSERT(!result.is_null()); | 8208 ASSERT(!result.is_null()); |
| 8209 return *result; | 8209 return *result; |
| 8210 } | 8210 } |
| 8211 | 8211 |
| 8212 | 8212 |
| 8213 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { | 8213 static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate, |
| 8214 HandleScope scope(isolate); | 8214 Handle<Object> constructor, |
| 8215 ASSERT(args.length() == 1); | 8215 Handle<AllocationSite> site) { |
| 8216 | |
| 8217 Handle<Object> constructor = args.at<Object>(0); | |
| 8218 | |
| 8219 // If the constructor isn't a proper function we throw a type error. | 8216 // If the constructor isn't a proper function we throw a type error. |
| 8220 if (!constructor->IsJSFunction()) { | 8217 if (!constructor->IsJSFunction()) { |
| 8221 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 8218 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
| 8222 Handle<Object> type_error = | 8219 Handle<Object> type_error = |
| 8223 isolate->factory()->NewTypeError("not_constructor", arguments); | 8220 isolate->factory()->NewTypeError("not_constructor", arguments); |
| 8224 return isolate->Throw(*type_error); | 8221 return isolate->Throw(*type_error); |
| 8225 } | 8222 } |
| 8226 | 8223 |
| 8227 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); | 8224 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
| 8228 | 8225 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8266 | 8263 |
| 8267 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | 8264 Handle<SharedFunctionInfo> shared(function->shared(), isolate); |
| 8268 if (!function->has_initial_map() && | 8265 if (!function->has_initial_map() && |
| 8269 shared->IsInobjectSlackTrackingInProgress()) { | 8266 shared->IsInobjectSlackTrackingInProgress()) { |
| 8270 // The tracking is already in progress for another function. We can only | 8267 // The tracking is already in progress for another function. We can only |
| 8271 // track one initial_map at a time, so we force the completion before the | 8268 // track one initial_map at a time, so we force the completion before the |
| 8272 // function is called as a constructor for the first time. | 8269 // function is called as a constructor for the first time. |
| 8273 shared->CompleteInobjectSlackTracking(); | 8270 shared->CompleteInobjectSlackTracking(); |
| 8274 } | 8271 } |
| 8275 | 8272 |
| 8276 Handle<JSObject> result = isolate->factory()->NewJSObject(function); | 8273 Handle<JSObject> result; |
| 8274 if (site.is_null()) { | |
| 8275 result = isolate->factory()->NewJSObject(function); | |
| 8276 } else { | |
| 8277 result = isolate->factory()->NewJSObjectWithMemento(function, site); | |
| 8278 } | |
| 8277 RETURN_IF_EMPTY_HANDLE(isolate, result); | 8279 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 8278 | 8280 |
| 8279 isolate->counters()->constructed_objects()->Increment(); | 8281 isolate->counters()->constructed_objects()->Increment(); |
| 8280 isolate->counters()->constructed_objects_runtime()->Increment(); | 8282 isolate->counters()->constructed_objects_runtime()->Increment(); |
| 8281 | 8283 |
| 8282 return *result; | 8284 return *result; |
| 8283 } | 8285 } |
| 8284 | 8286 |
| 8285 | 8287 |
| 8288 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { | |
| 8289 HandleScope scope(isolate); | |
| 8290 ASSERT(args.length() == 1); | |
| 8291 | |
| 8292 Handle<Object> constructor = args.at<Object>(0); | |
| 8293 return Runtime_NewObjectHelper(isolate, | |
| 8294 constructor, | |
| 8295 Handle<AllocationSite>::null()); | |
| 8296 } | |
| 8297 | |
| 8298 | |
| 8299 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectWithAllocationSite) { | |
| 8300 HandleScope scope(isolate); | |
| 8301 ASSERT(args.length() == 2); | |
| 8302 | |
| 8303 Handle<Object> constructor = args.at<Object>(1); | |
| 8304 // TODO(mvstanton): make this a real site | |
|
Hannes Payer (out of office)
2014/02/18 16:24:26
ambiguous comment
mvstanton
2014/02/19 08:40:26
Done.
| |
| 8305 Handle<Object> feedback = args.at<Object>(0); | |
| 8306 Handle<AllocationSite> site; | |
| 8307 if (feedback->IsAllocationSite()) { | |
| 8308 site = Handle<AllocationSite>::cast(feedback); | |
| 8309 } | |
| 8310 return Runtime_NewObjectHelper(isolate, | |
| 8311 constructor, | |
| 8312 site); | |
| 8313 } | |
| 8314 | |
| 8315 | |
| 8286 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinalizeInstanceSize) { | 8316 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinalizeInstanceSize) { |
| 8287 HandleScope scope(isolate); | 8317 HandleScope scope(isolate); |
| 8288 ASSERT(args.length() == 1); | 8318 ASSERT(args.length() == 1); |
| 8289 | 8319 |
| 8290 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8320 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8291 function->shared()->CompleteInobjectSlackTracking(); | 8321 function->shared()->CompleteInobjectSlackTracking(); |
| 8292 | 8322 |
| 8293 return isolate->heap()->undefined_value(); | 8323 return isolate->heap()->undefined_value(); |
| 8294 } | 8324 } |
| 8295 | 8325 |
| (...skipping 6583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14879 // Handle last resort GC and make sure to allow future allocations | 14909 // Handle last resort GC and make sure to allow future allocations |
| 14880 // to grow the heap without causing GCs (if possible). | 14910 // to grow the heap without causing GCs (if possible). |
| 14881 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14911 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14882 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14912 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14883 "Runtime::PerformGC"); | 14913 "Runtime::PerformGC"); |
| 14884 } | 14914 } |
| 14885 } | 14915 } |
| 14886 | 14916 |
| 14887 | 14917 |
| 14888 } } // namespace v8::internal | 14918 } } // namespace v8::internal |
| OLD | NEW |