| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 Handle<FixedArray> elements) { | 508 Handle<FixedArray> elements) { |
| 509 // Check if boilerplate exists. If not, create it first. | 509 // Check if boilerplate exists. If not, create it first. |
| 510 Handle<Object> literal_site(literals->get(literals_index), isolate); | 510 Handle<Object> literal_site(literals->get(literals_index), isolate); |
| 511 Handle<AllocationSite> site; | 511 Handle<AllocationSite> site; |
| 512 if (*literal_site == isolate->heap()->undefined_value()) { | 512 if (*literal_site == isolate->heap()->undefined_value()) { |
| 513 ASSERT(*elements != isolate->heap()->empty_fixed_array()); | 513 ASSERT(*elements != isolate->heap()->empty_fixed_array()); |
| 514 Handle<Object> boilerplate = | 514 Handle<Object> boilerplate = |
| 515 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); | 515 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); |
| 516 if (boilerplate.is_null()) return site; | 516 if (boilerplate.is_null()) return site; |
| 517 site = isolate->factory()->NewAllocationSite(); | 517 site = isolate->factory()->NewAllocationSite(); |
| 518 site->set_payload(*boilerplate); | 518 site->set_transition_info(*boilerplate); |
| 519 literals->set(literals_index, *site); | 519 literals->set(literals_index, *site); |
| 520 } else { | 520 } else { |
| 521 site = Handle<AllocationSite>::cast(literal_site); | 521 site = Handle<AllocationSite>::cast(literal_site); |
| 522 } | 522 } |
| 523 | 523 |
| 524 return site; | 524 return site; |
| 525 } | 525 } |
| 526 | 526 |
| 527 | 527 |
| 528 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { | 528 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { |
| 529 HandleScope scope(isolate); | 529 HandleScope scope(isolate); |
| 530 ASSERT(args.length() == 3); | 530 ASSERT(args.length() == 3); |
| 531 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 531 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 532 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 532 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 533 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 533 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 534 | 534 |
| 535 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, | 535 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
| 536 literals_index, elements); | 536 literals_index, elements); |
| 537 RETURN_IF_EMPTY_HANDLE(isolate, site); | 537 RETURN_IF_EMPTY_HANDLE(isolate, site); |
| 538 | 538 |
| 539 JSObject* boilerplate = JSObject::cast(site->payload()); | 539 JSObject* boilerplate = JSObject::cast(site->transition_info()); |
| 540 return boilerplate->DeepCopy(isolate); | 540 return boilerplate->DeepCopy(isolate); |
| 541 } | 541 } |
| 542 | 542 |
| 543 | 543 |
| 544 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { | 544 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { |
| 545 HandleScope scope(isolate); | 545 HandleScope scope(isolate); |
| 546 ASSERT(args.length() == 3); | 546 ASSERT(args.length() == 3); |
| 547 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 547 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
| 548 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 548 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
| 549 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 549 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
| 550 | 550 |
| 551 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, | 551 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, |
| 552 literals_index, elements); | 552 literals_index, elements); |
| 553 RETURN_IF_EMPTY_HANDLE(isolate, site); | 553 RETURN_IF_EMPTY_HANDLE(isolate, site); |
| 554 | 554 |
| 555 JSObject* boilerplate = JSObject::cast(site->payload()); | 555 JSObject* boilerplate = JSObject::cast(site->transition_info()); |
| 556 if (boilerplate->elements()->map() == | 556 if (boilerplate->elements()->map() == |
| 557 isolate->heap()->fixed_cow_array_map()) { | 557 isolate->heap()->fixed_cow_array_map()) { |
| 558 isolate->counters()->cow_arrays_created_runtime()->Increment(); | 558 isolate->counters()->cow_arrays_created_runtime()->Increment(); |
| 559 } | 559 } |
| 560 | 560 |
| 561 AllocationSiteMode mode = AllocationSite::GetMode( | 561 AllocationSiteMode mode = AllocationSite::GetMode( |
| 562 boilerplate->GetElementsKind()); | 562 boilerplate->GetElementsKind()); |
| 563 if (mode == TRACK_ALLOCATION_SITE) { | 563 if (mode == TRACK_ALLOCATION_SITE) { |
| 564 return isolate->heap()->CopyJSObjectWithAllocationSite( | 564 return isolate->heap()->CopyJSObjectWithAllocationSite( |
| 565 boilerplate, *site); | 565 boilerplate, *site); |
| (...skipping 4648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5214 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5214 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 5215 CONVERT_SMI_ARG_CHECKED(store_index, 1); | 5215 CONVERT_SMI_ARG_CHECKED(store_index, 1); |
| 5216 Handle<Object> value = args.at<Object>(2); | 5216 Handle<Object> value = args.at<Object>(2); |
| 5217 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); | 5217 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); |
| 5218 CONVERT_SMI_ARG_CHECKED(literal_index, 4); | 5218 CONVERT_SMI_ARG_CHECKED(literal_index, 4); |
| 5219 | 5219 |
| 5220 Object* raw_literal_cell = literals->get(literal_index); | 5220 Object* raw_literal_cell = literals->get(literal_index); |
| 5221 JSArray* boilerplate = NULL; | 5221 JSArray* boilerplate = NULL; |
| 5222 if (raw_literal_cell->IsAllocationSite()) { | 5222 if (raw_literal_cell->IsAllocationSite()) { |
| 5223 AllocationSite* site = AllocationSite::cast(raw_literal_cell); | 5223 AllocationSite* site = AllocationSite::cast(raw_literal_cell); |
| 5224 boilerplate = JSArray::cast(site->payload()); | 5224 boilerplate = JSArray::cast(site->transition_info()); |
| 5225 } else { | 5225 } else { |
| 5226 boilerplate = JSArray::cast(raw_literal_cell); | 5226 boilerplate = JSArray::cast(raw_literal_cell); |
| 5227 } | 5227 } |
| 5228 Handle<JSArray> boilerplate_object(boilerplate); | 5228 Handle<JSArray> boilerplate_object(boilerplate); |
| 5229 ElementsKind elements_kind = object->GetElementsKind(); | 5229 ElementsKind elements_kind = object->GetElementsKind(); |
| 5230 ASSERT(IsFastElementsKind(elements_kind)); | 5230 ASSERT(IsFastElementsKind(elements_kind)); |
| 5231 // Smis should never trigger transitions. | 5231 // Smis should never trigger transitions. |
| 5232 ASSERT(!value->IsSmi()); | 5232 ASSERT(!value->IsSmi()); |
| 5233 | 5233 |
| 5234 if (value->IsNumber()) { | 5234 if (value->IsNumber()) { |
| (...skipping 5819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11054 if (at_return) { | 11054 if (at_return) { |
| 11055 details->set(details_index++, *return_value); | 11055 details->set(details_index++, *return_value); |
| 11056 } | 11056 } |
| 11057 | 11057 |
| 11058 // Add the receiver (same as in function frame). | 11058 // Add the receiver (same as in function frame). |
| 11059 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | 11059 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
| 11060 // THE FRAME ITERATOR TO WRAP THE RECEIVER. | 11060 // THE FRAME ITERATOR TO WRAP THE RECEIVER. |
| 11061 Handle<Object> receiver(it.frame()->receiver(), isolate); | 11061 Handle<Object> receiver(it.frame()->receiver(), isolate); |
| 11062 if (!receiver->IsJSObject() && | 11062 if (!receiver->IsJSObject() && |
| 11063 shared->is_classic_mode() && | 11063 shared->is_classic_mode() && |
| 11064 !shared->native()) { | 11064 !function->IsBuiltin()) { |
| 11065 // If the receiver is not a JSObject and the function is not a | 11065 // If the receiver is not a JSObject and the function is not a |
| 11066 // builtin or strict-mode we have hit an optimization where a | 11066 // builtin or strict-mode we have hit an optimization where a |
| 11067 // value object is not converted into a wrapped JS objects. To | 11067 // value object is not converted into a wrapped JS objects. To |
| 11068 // hide this optimization from the debugger, we wrap the receiver | 11068 // hide this optimization from the debugger, we wrap the receiver |
| 11069 // by creating correct wrapper object based on the calling frame's | 11069 // by creating correct wrapper object based on the calling frame's |
| 11070 // native context. | 11070 // native context. |
| 11071 it.Advance(); | 11071 it.Advance(); |
| 11072 Handle<Context> calling_frames_native_context( | 11072 Handle<Context> calling_frames_native_context( |
| 11073 Context::cast(Context::cast(it.frame()->context())->native_context())); | 11073 Context::cast(Context::cast(it.frame()->context())->native_context())); |
| 11074 ASSERT(!receiver->IsUndefined() && !receiver->IsNull()); |
| 11074 receiver = | 11075 receiver = |
| 11075 isolate->factory()->ToObject(receiver, calling_frames_native_context); | 11076 isolate->factory()->ToObject(receiver, calling_frames_native_context); |
| 11076 } | 11077 } |
| 11077 details->set(kFrameDetailsReceiverIndex, *receiver); | 11078 details->set(kFrameDetailsReceiverIndex, *receiver); |
| 11078 | 11079 |
| 11079 ASSERT_EQ(details_size, details_index); | 11080 ASSERT_EQ(details_size, details_index); |
| 11080 return *isolate->factory()->NewJSArrayWithElements(details); | 11081 return *isolate->factory()->NewJSArrayWithElements(details); |
| 11081 } | 11082 } |
| 11082 | 11083 |
| 11083 | 11084 |
| (...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13838 JSArray* array; | 13839 JSArray* array; |
| 13839 MaybeObject* maybe_array; | 13840 MaybeObject* maybe_array; |
| 13840 if (!type_info.is_null() && | 13841 if (!type_info.is_null() && |
| 13841 *type_info != isolate->heap()->undefined_value() && | 13842 *type_info != isolate->heap()->undefined_value() && |
| 13842 Cell::cast(*type_info)->value()->IsAllocationSite() && | 13843 Cell::cast(*type_info)->value()->IsAllocationSite() && |
| 13843 can_use_type_feedback) { | 13844 can_use_type_feedback) { |
| 13844 Handle<Cell> cell = Handle<Cell>::cast(type_info); | 13845 Handle<Cell> cell = Handle<Cell>::cast(type_info); |
| 13845 Handle<AllocationSite> site = Handle<AllocationSite>( | 13846 Handle<AllocationSite> site = Handle<AllocationSite>( |
| 13846 AllocationSite::cast(cell->value()), isolate); | 13847 AllocationSite::cast(cell->value()), isolate); |
| 13847 ASSERT(!site->IsLiteralSite()); | 13848 ASSERT(!site->IsLiteralSite()); |
| 13848 ElementsKind to_kind = site->GetElementsKindPayload(); | 13849 ElementsKind to_kind = site->GetElementsKind(); |
| 13849 if (holey && !IsFastHoleyElementsKind(to_kind)) { | 13850 if (holey && !IsFastHoleyElementsKind(to_kind)) { |
| 13850 to_kind = GetHoleyElementsKind(to_kind); | 13851 to_kind = GetHoleyElementsKind(to_kind); |
| 13851 // Update the allocation site info to reflect the advice alteration. | 13852 // Update the allocation site info to reflect the advice alteration. |
| 13852 site->SetElementsKindPayload(to_kind); | 13853 site->SetElementsKind(to_kind); |
| 13853 } | 13854 } |
| 13854 | 13855 |
| 13855 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( | 13856 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( |
| 13856 *constructor, site); | 13857 *constructor, site); |
| 13857 if (!maybe_array->To(&array)) return maybe_array; | 13858 if (!maybe_array->To(&array)) return maybe_array; |
| 13858 } else { | 13859 } else { |
| 13859 maybe_array = isolate->heap()->AllocateJSObject(*constructor); | 13860 maybe_array = isolate->heap()->AllocateJSObject(*constructor); |
| 13860 if (!maybe_array->To(&array)) return maybe_array; | 13861 if (!maybe_array->To(&array)) return maybe_array; |
| 13861 // We might need to transition to holey | 13862 // We might need to transition to holey |
| 13862 ElementsKind kind = constructor->initial_map()->elements_kind(); | 13863 ElementsKind kind = constructor->initial_map()->elements_kind(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13995 // Handle last resort GC and make sure to allow future allocations | 13996 // Handle last resort GC and make sure to allow future allocations |
| 13996 // to grow the heap without causing GCs (if possible). | 13997 // to grow the heap without causing GCs (if possible). |
| 13997 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13998 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13998 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13999 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13999 "Runtime::PerformGC"); | 14000 "Runtime::PerformGC"); |
| 14000 } | 14001 } |
| 14001 } | 14002 } |
| 14002 | 14003 |
| 14003 | 14004 |
| 14004 } } // namespace v8::internal | 14005 } } // namespace v8::internal |
| OLD | NEW |