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 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3117 return *target; | 3117 return *target; |
3118 } | 3118 } |
3119 | 3119 |
3120 | 3120 |
3121 RUNTIME_FUNCTION(Runtime_SetExpectedNumberOfProperties) { | 3121 RUNTIME_FUNCTION(Runtime_SetExpectedNumberOfProperties) { |
3122 HandleScope scope(isolate); | 3122 HandleScope scope(isolate); |
3123 ASSERT(args.length() == 2); | 3123 ASSERT(args.length() == 2); |
3124 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 3124 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
3125 CONVERT_SMI_ARG_CHECKED(num, 1); | 3125 CONVERT_SMI_ARG_CHECKED(num, 1); |
3126 RUNTIME_ASSERT(num >= 0); | 3126 RUNTIME_ASSERT(num >= 0); |
3127 // If objects constructed from this function exist then changing | 3127 |
3128 // 'estimated_nof_properties' is dangerous since the previous value might | 3128 func->shared()->set_expected_nof_properties(num); |
3129 // have been compiled into the fast construct stub. Moreover, the inobject | 3129 if (func->has_initial_map()) { |
3130 // slack tracking logic might have adjusted the previous value, so even | 3130 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); |
3131 // passing the same value is risky. | 3131 new_initial_map->set_unused_property_fields(num); |
3132 if (!func->shared()->live_objects_may_exist()) { | 3132 func->set_initial_map(*new_initial_map); |
3133 func->shared()->set_expected_nof_properties(num); | |
3134 if (func->has_initial_map()) { | |
3135 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); | |
3136 new_initial_map->set_unused_property_fields(num); | |
3137 func->set_initial_map(*new_initial_map); | |
3138 } | |
3139 } | 3133 } |
3140 return isolate->heap()->undefined_value(); | 3134 return isolate->heap()->undefined_value(); |
3141 } | 3135 } |
3142 | 3136 |
3143 | 3137 |
3144 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { | 3138 RUNTIME_FUNCTION(RuntimeHidden_CreateJSGeneratorObject) { |
3145 HandleScope scope(isolate); | 3139 HandleScope scope(isolate); |
3146 ASSERT(args.length() == 0); | 3140 ASSERT(args.length() == 0); |
3147 | 3141 |
3148 JavaScriptFrameIterator it(isolate); | 3142 JavaScriptFrameIterator it(isolate); |
(...skipping 5216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8365 // reported the same way whether or not 'Function' is called | 8359 // reported the same way whether or not 'Function' is called |
8366 // using 'new'. | 8360 // using 'new'. |
8367 return isolate->context()->global_object(); | 8361 return isolate->context()->global_object(); |
8368 } | 8362 } |
8369 } | 8363 } |
8370 | 8364 |
8371 // The function should be compiled for the optimization hints to be | 8365 // The function should be compiled for the optimization hints to be |
8372 // available. | 8366 // available. |
8373 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); | 8367 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION); |
8374 | 8368 |
8375 Handle<SharedFunctionInfo> shared(function->shared(), isolate); | |
8376 if (!function->has_initial_map() && | |
8377 shared->IsInobjectSlackTrackingInProgress()) { | |
8378 // The tracking is already in progress for another function. We can only | |
8379 // track one initial_map at a time, so we force the completion before the | |
8380 // function is called as a constructor for the first time. | |
8381 shared->CompleteInobjectSlackTracking(); | |
8382 } | |
8383 | |
8384 Handle<JSObject> result; | 8369 Handle<JSObject> result; |
8385 if (site.is_null()) { | 8370 if (site.is_null()) { |
8386 result = isolate->factory()->NewJSObject(function); | 8371 result = isolate->factory()->NewJSObject(function); |
8387 } else { | 8372 } else { |
8388 result = isolate->factory()->NewJSObjectWithMemento(function, site); | 8373 result = isolate->factory()->NewJSObjectWithMemento(function, site); |
8389 } | 8374 } |
8390 | 8375 |
8391 isolate->counters()->constructed_objects()->Increment(); | 8376 isolate->counters()->constructed_objects()->Increment(); |
8392 isolate->counters()->constructed_objects_runtime()->Increment(); | 8377 isolate->counters()->constructed_objects_runtime()->Increment(); |
8393 | 8378 |
(...skipping 23 matching lines...) Expand all Loading... |
8417 } | 8402 } |
8418 return Runtime_NewObjectHelper(isolate, constructor, site); | 8403 return Runtime_NewObjectHelper(isolate, constructor, site); |
8419 } | 8404 } |
8420 | 8405 |
8421 | 8406 |
8422 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { | 8407 RUNTIME_FUNCTION(RuntimeHidden_FinalizeInstanceSize) { |
8423 HandleScope scope(isolate); | 8408 HandleScope scope(isolate); |
8424 ASSERT(args.length() == 1); | 8409 ASSERT(args.length() == 1); |
8425 | 8410 |
8426 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8411 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8427 function->shared()->CompleteInobjectSlackTracking(); | 8412 function->CompleteInobjectSlackTracking(); |
8428 | 8413 |
8429 return isolate->heap()->undefined_value(); | 8414 return isolate->heap()->undefined_value(); |
8430 } | 8415 } |
8431 | 8416 |
8432 | 8417 |
8433 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { | 8418 RUNTIME_FUNCTION(RuntimeHidden_CompileUnoptimized) { |
8434 HandleScope scope(isolate); | 8419 HandleScope scope(isolate); |
8435 ASSERT(args.length() == 1); | 8420 ASSERT(args.length() == 1); |
8436 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8421 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8437 #ifdef DEBUG | 8422 #ifdef DEBUG |
(...skipping 6765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15203 } | 15188 } |
15204 return NULL; | 15189 return NULL; |
15205 } | 15190 } |
15206 | 15191 |
15207 | 15192 |
15208 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15193 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15209 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15194 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15210 } | 15195 } |
15211 | 15196 |
15212 } } // namespace v8::internal | 15197 } } // namespace v8::internal |
OLD | NEW |