| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "v8.h" | 8 #include "v8.h" |
| 9 | 9 |
| 10 #include "accessors.h" | 10 #include "accessors.h" |
| (...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3132 return *target; | 3132 return *target; |
| 3133 } | 3133 } |
| 3134 | 3134 |
| 3135 | 3135 |
| 3136 RUNTIME_FUNCTION(Runtime_SetExpectedNumberOfProperties) { | 3136 RUNTIME_FUNCTION(Runtime_SetExpectedNumberOfProperties) { |
| 3137 HandleScope scope(isolate); | 3137 HandleScope scope(isolate); |
| 3138 ASSERT(args.length() == 2); | 3138 ASSERT(args.length() == 2); |
| 3139 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 3139 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
| 3140 CONVERT_SMI_ARG_CHECKED(num, 1); | 3140 CONVERT_SMI_ARG_CHECKED(num, 1); |
| 3141 RUNTIME_ASSERT(num >= 0); | 3141 RUNTIME_ASSERT(num >= 0); |
| 3142 // If objects constructed from this function exist then changing | 3142 |
| 3143 // 'estimated_nof_properties' is dangerous since the previous value might | 3143 func->shared()->set_expected_nof_properties(num); |
| 3144 // have been compiled into the fast construct stub. Moreover, the inobject | 3144 if (func->has_initial_map()) { |
| 3145 // slack tracking logic might have adjusted the previous value, so even | 3145 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); |
| 3146 // passing the same value is risky. | 3146 new_initial_map->set_unused_property_fields(num); |
| 3147 if (!func->shared()->live_objects_may_exist()) { | 3147 func->set_initial_map(*new_initial_map); |
| 3148 func->shared()->set_expected_nof_properties(num); | |
| 3149 if (func->has_initial_map()) { | |
| 3150 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); | |
| 3151 new_initial_map->set_unused_property_fields(num); | |
| 3152 func->set_initial_map(*new_initial_map); | |
| 3153 } | |
| 3154 } | 3148 } |
| 3155 return isolate->heap()->undefined_value(); | 3149 return isolate->heap()->undefined_value(); |
| 3156 } | 3150 } |
| 3157 | 3151 |
| 3158 | 3152 |
| 3159 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { | 3153 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { |
| 3160 HandleScope scope(isolate); | 3154 HandleScope scope(isolate); |
| 3161 ASSERT(args.length() == 0); | 3155 ASSERT(args.length() == 0); |
| 3162 | 3156 |
| 3163 JavaScriptFrameIterator it(isolate); | 3157 JavaScriptFrameIterator it(isolate); |
| (...skipping 5216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8380 // reported the same way whether or not 'Function' is called | 8374 // reported the same way whether or not 'Function' is called |
| 8381 // using 'new'. | 8375 // using 'new'. |
| 8382 return isolate->context()->global_object(); | 8376 return isolate->context()->global_object(); |
| 8383 } | 8377 } |
| 8384 } | 8378 } |
| 8385 | 8379 |
| 8386 // The function should be compiled for the optimization hints to be | 8380 // The function should be compiled for the optimization hints to be |
| 8387 // available. | 8381 // available. |
| 8388 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); | 8382 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); |
| 8389 | 8383 |
| 8390 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | |
| 8391 if (!function->has_initial_map() && | |
| 8392 shared->IsInobjectSlackTrackingInProgress()) { | |
| 8393 // The tracking is already in progress for another function. We can only | |
| 8394 // track one initial_map at a time, so we force the completion before the | |
| 8395 // function is called as a constructor for the first time. | |
| 8396 shared->CompleteInobjectSlackTracking(); | |
| 8397 } | |
| 8398 | |
| 8399 Handle<JSObject> result; | 8384 Handle<JSObject> result; |
| 8400 if (site.is_null()) { | 8385 if (site.is_null()) { |
| 8401 result = isolate->factory()->NewJSObject(function); | 8386 result = isolate->factory()->NewJSObject(function); |
| 8402 } else { | 8387 } else { |
| 8403 result = isolate->factory()->NewJSObjectWithMemento(function, site); | 8388 result = isolate->factory()->NewJSObjectWithMemento(function, site); |
| 8404 } | 8389 } |
| 8405 | 8390 |
| 8406 isolate->counters()->constructed_objects()->Increment(); | 8391 isolate->counters()->constructed_objects()->Increment(); |
| 8407 isolate->counters()->constructed_objects_runtime()->Increment(); | 8392 isolate->counters()->constructed_objects_runtime()->Increment(); |
| 8408 | 8393 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 8432 } | 8417 } |
| 8433 return Runtime_NewObjectHelper(isolate, constructor, site); | 8418 return Runtime_NewObjectHelper(isolate, constructor, site); |
| 8434 } | 8419 } |
| 8435 | 8420 |
| 8436 | 8421 |
| 8437 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { | 8422 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { |
| 8438 HandleScope scope(isolate); | 8423 HandleScope scope(isolate); |
| 8439 ASSERT(args.length() == 1); | 8424 ASSERT(args.length() == 1); |
| 8440 | 8425 |
| 8441 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8426 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8442 function->shared()->CompleteInobjectSlackTracking(); | 8427 function->CompleteInobjectSlackTracking(); |
| 8443 | 8428 |
| 8444 return isolate->heap()->undefined_value(); | 8429 return isolate->heap()->undefined_value(); |
| 8445 } | 8430 } |
| 8446 | 8431 |
| 8447 | 8432 |
| 8448 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { | 8433 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { |
| 8449 HandleScope scope(isolate); | 8434 HandleScope scope(isolate); |
| 8450 ASSERT(args.length() == 1); | 8435 ASSERT(args.length() == 1); |
| 8451 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8436 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8452 #ifdef DEBUG | 8437 #ifdef DEBUG |
| (...skipping 6775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15228 } | 15213 } |
| 15229 return NULL; | 15214 return NULL; |
| 15230 } | 15215 } |
| 15231 | 15216 |
| 15232 | 15217 |
| 15233 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15218 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15234 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15219 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15235 } | 15220 } |
| 15236 | 15221 |
| 15237 } } // namespace v8::internal | 15222 } } // namespace v8::internal |
| OLD | NEW |