| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // slow properties mode for now. We don't go in the map cache because | 252 // slow properties mode for now. We don't go in the map cache because |
| 253 // maps with constant functions can't be shared if the functions are | 253 // maps with constant functions can't be shared if the functions are |
| 254 // not the same (which is the common case). | 254 // not the same (which is the common case). |
| 255 bool is_result_from_cache = false; | 255 bool is_result_from_cache = false; |
| 256 Handle<Map> map = has_function_literal | 256 Handle<Map> map = has_function_literal |
| 257 ? Handle<Map>(context->object_function()->initial_map()) | 257 ? Handle<Map>(context->object_function()->initial_map()) |
| 258 : ComputeObjectLiteralMap(context, | 258 : ComputeObjectLiteralMap(context, |
| 259 constant_properties, | 259 constant_properties, |
| 260 &is_result_from_cache); | 260 &is_result_from_cache); |
| 261 | 261 |
| 262 PretenureFlag pretenure_flag = |
| 263 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; |
| 264 |
| 262 Handle<JSObject> boilerplate = | 265 Handle<JSObject> boilerplate = |
| 263 isolate->factory()->NewJSObjectFromMap( | 266 isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); |
| 264 map, isolate->heap()->GetPretenureMode()); | |
| 265 | 267 |
| 266 // Normalize the elements of the boilerplate to save space if needed. | 268 // Normalize the elements of the boilerplate to save space if needed. |
| 267 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); | 269 if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); |
| 268 | 270 |
| 269 // Add the constant properties to the boilerplate. | 271 // Add the constant properties to the boilerplate. |
| 270 int length = constant_properties->length(); | 272 int length = constant_properties->length(); |
| 271 bool should_transform = | 273 bool should_transform = |
| 272 !is_result_from_cache && boilerplate->HasFastProperties(); | 274 !is_result_from_cache && boilerplate->HasFastProperties(); |
| 273 if (should_transform || has_function_literal) { | 275 if (should_transform || has_function_literal) { |
| 274 // Normalize the properties of object to avoid n^2 behavior | 276 // Normalize the properties of object to avoid n^2 behavior |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 362 |
| 361 | 363 |
| 362 Handle<Object> Runtime::CreateArrayLiteralBoilerplate( | 364 Handle<Object> Runtime::CreateArrayLiteralBoilerplate( |
| 363 Isolate* isolate, | 365 Isolate* isolate, |
| 364 Handle<FixedArray> literals, | 366 Handle<FixedArray> literals, |
| 365 Handle<FixedArray> elements) { | 367 Handle<FixedArray> elements) { |
| 366 // Create the JSArray. | 368 // Create the JSArray. |
| 367 Handle<JSFunction> constructor( | 369 Handle<JSFunction> constructor( |
| 368 JSFunction::NativeContextFromLiterals(*literals)->array_function()); | 370 JSFunction::NativeContextFromLiterals(*literals)->array_function()); |
| 369 | 371 |
| 372 PretenureFlag pretenure_flag = |
| 373 isolate->heap()->InNewSpace(*literals) ? NOT_TENURED : TENURED; |
| 374 |
| 370 Handle<JSArray> object = Handle<JSArray>::cast( | 375 Handle<JSArray> object = Handle<JSArray>::cast( |
| 371 isolate->factory()->NewJSObject( | 376 isolate->factory()->NewJSObject(constructor, pretenure_flag)); |
| 372 constructor, isolate->heap()->GetPretenureMode())); | |
| 373 | 377 |
| 374 ElementsKind constant_elements_kind = | 378 ElementsKind constant_elements_kind = |
| 375 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); | 379 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); |
| 376 Handle<FixedArrayBase> constant_elements_values( | 380 Handle<FixedArrayBase> constant_elements_values( |
| 377 FixedArrayBase::cast(elements->get(1))); | 381 FixedArrayBase::cast(elements->get(1))); |
| 378 | 382 |
| 379 ASSERT(IsFastElementsKind(constant_elements_kind)); | 383 ASSERT(IsFastElementsKind(constant_elements_kind)); |
| 380 Context* native_context = isolate->context()->native_context(); | 384 Context* native_context = isolate->context()->native_context(); |
| 381 Object* maybe_maps_array = native_context->js_array_maps(); | 385 Object* maybe_maps_array = native_context->js_array_maps(); |
| 382 ASSERT(!maybe_maps_array->IsUndefined()); | 386 ASSERT(!maybe_maps_array->IsUndefined()); |
| (...skipping 6419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6802 } | 6806 } |
| 6803 | 6807 |
| 6804 | 6808 |
| 6805 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { | 6809 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { |
| 6806 SealHandleScope shs(isolate); | 6810 SealHandleScope shs(isolate); |
| 6807 ASSERT(args.length() == 1); | 6811 ASSERT(args.length() == 1); |
| 6808 | 6812 |
| 6809 Object* number = args[0]; | 6813 Object* number = args[0]; |
| 6810 RUNTIME_ASSERT(number->IsNumber()); | 6814 RUNTIME_ASSERT(number->IsNumber()); |
| 6811 | 6815 |
| 6812 return isolate->heap()->NumberToString( | 6816 return isolate->heap()->NumberToString(number, false); |
| 6813 number, false, isolate->heap()->GetPretenureMode()); | |
| 6814 } | 6817 } |
| 6815 | 6818 |
| 6816 | 6819 |
| 6817 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6820 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
| 6818 SealHandleScope shs(isolate); | 6821 SealHandleScope shs(isolate); |
| 6819 ASSERT(args.length() == 1); | 6822 ASSERT(args.length() == 1); |
| 6820 | 6823 |
| 6821 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6824 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6822 | 6825 |
| 6823 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6826 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| (...skipping 8072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14896 // Handle last resort GC and make sure to allow future allocations | 14899 // Handle last resort GC and make sure to allow future allocations |
| 14897 // to grow the heap without causing GCs (if possible). | 14900 // to grow the heap without causing GCs (if possible). |
| 14898 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14901 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14899 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14902 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14900 "Runtime::PerformGC"); | 14903 "Runtime::PerformGC"); |
| 14901 } | 14904 } |
| 14902 } | 14905 } |
| 14903 | 14906 |
| 14904 | 14907 |
| 14905 } } // namespace v8::internal | 14908 } } // namespace v8::internal |
| OLD | NEW |