| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Creating object copy for literals. No strict mode needed. | 164 // Creating object copy for literals. No strict mode needed. |
| 165 copy->SetProperty(key_string, result, NONE, kNonStrictMode); | 165 copy->SetProperty(key_string, result, NONE, kNonStrictMode); |
| 166 if (!maybe_result->ToObject(&result)) return maybe_result; | 166 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Deep copy local elements. | 172 // Deep copy local elements. |
| 173 // Pixel elements cannot be created using an object literal. | 173 // Pixel elements cannot be created using an object literal. |
| 174 ASSERT(!copy->HasPixelElements() && !copy->HasExternalArrayElements()); | 174 ASSERT(!copy->HasExternalArrayElements()); |
| 175 switch (copy->GetElementsKind()) { | 175 switch (copy->GetElementsKind()) { |
| 176 case JSObject::FAST_ELEMENTS: { | 176 case JSObject::FAST_ELEMENTS: { |
| 177 FixedArray* elements = FixedArray::cast(copy->elements()); | 177 FixedArray* elements = FixedArray::cast(copy->elements()); |
| 178 if (elements->map() == heap->fixed_cow_array_map()) { | 178 if (elements->map() == heap->fixed_cow_array_map()) { |
| 179 isolate->counters()->cow_arrays_created_runtime()->Increment(); | 179 isolate->counters()->cow_arrays_created_runtime()->Increment(); |
| 180 #ifdef DEBUG | 180 #ifdef DEBUG |
| 181 for (int i = 0; i < elements->length(); i++) { | 181 for (int i = 0; i < elements->length(); i++) { |
| 182 ASSERT(!elements->get(i)->IsJSObject()); | 182 ASSERT(!elements->get(i)->IsJSObject()); |
| 183 } | 183 } |
| 184 #endif | 184 #endif |
| (...skipping 4356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4541 RUNTIME_GET_ISOLATE; | 4541 RUNTIME_GET_ISOLATE; |
| 4542 NoHandleAllocation ha; | 4542 NoHandleAllocation ha; |
| 4543 ASSERT(args.length() == 1); | 4543 ASSERT(args.length() == 1); |
| 4544 | 4544 |
| 4545 // Compute the frame holding the arguments. | 4545 // Compute the frame holding the arguments. |
| 4546 JavaScriptFrameIterator it; | 4546 JavaScriptFrameIterator it; |
| 4547 it.AdvanceToArgumentsFrame(); | 4547 it.AdvanceToArgumentsFrame(); |
| 4548 JavaScriptFrame* frame = it.frame(); | 4548 JavaScriptFrame* frame = it.frame(); |
| 4549 | 4549 |
| 4550 // Get the actual number of provided arguments. | 4550 // Get the actual number of provided arguments. |
| 4551 const uint32_t n = frame->GetProvidedParametersCount(); | 4551 const uint32_t n = frame->ComputeParametersCount(); |
| 4552 | 4552 |
| 4553 // Try to convert the key to an index. If successful and within | 4553 // Try to convert the key to an index. If successful and within |
| 4554 // index return the the argument from the frame. | 4554 // index return the the argument from the frame. |
| 4555 uint32_t index; | 4555 uint32_t index; |
| 4556 if (args[0]->ToArrayIndex(&index) && index < n) { | 4556 if (args[0]->ToArrayIndex(&index) && index < n) { |
| 4557 return frame->GetParameter(index); | 4557 return frame->GetParameter(index); |
| 4558 } | 4558 } |
| 4559 | 4559 |
| 4560 // Convert the key to a string. | 4560 // Convert the key to a string. |
| 4561 HandleScope scope(isolate); | 4561 HandleScope scope(isolate); |
| (...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7195 bound_args = FixedArray::cast(params->elements()); | 7195 bound_args = FixedArray::cast(params->elements()); |
| 7196 bound_argc = Smi::cast(params->length())->value(); | 7196 bound_argc = Smi::cast(params->length())->value(); |
| 7197 } | 7197 } |
| 7198 | 7198 |
| 7199 // Find frame containing arguments passed to the caller. | 7199 // Find frame containing arguments passed to the caller. |
| 7200 JavaScriptFrameIterator it; | 7200 JavaScriptFrameIterator it; |
| 7201 JavaScriptFrame* frame = it.frame(); | 7201 JavaScriptFrame* frame = it.frame(); |
| 7202 ASSERT(!frame->is_optimized()); | 7202 ASSERT(!frame->is_optimized()); |
| 7203 it.AdvanceToArgumentsFrame(); | 7203 it.AdvanceToArgumentsFrame(); |
| 7204 frame = it.frame(); | 7204 frame = it.frame(); |
| 7205 int argc = frame->GetProvidedParametersCount(); | 7205 int argc = frame->ComputeParametersCount(); |
| 7206 | 7206 |
| 7207 // Prepend bound arguments to caller's arguments. | 7207 // Prepend bound arguments to caller's arguments. |
| 7208 int total_argc = bound_argc + argc; | 7208 int total_argc = bound_argc + argc; |
| 7209 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); | 7209 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); |
| 7210 for (int i = 0; i < bound_argc; i++) { | 7210 for (int i = 0; i < bound_argc; i++) { |
| 7211 Handle<Object> val = Handle<Object>(bound_args->get(i)); | 7211 Handle<Object> val = Handle<Object>(bound_args->get(i)); |
| 7212 param_data[i] = val.location(); | 7212 param_data[i] = val.location(); |
| 7213 } | 7213 } |
| 7214 for (int i = 0; i < argc; i++) { | 7214 for (int i = 0; i < argc; i++) { |
| 7215 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); | 7215 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8067 if (fun->IsJSFunction()) { | 8067 if (fun->IsJSFunction()) { |
| 8068 PrintObject(JSFunction::cast(fun)->shared()->name()); | 8068 PrintObject(JSFunction::cast(fun)->shared()->name()); |
| 8069 } else { | 8069 } else { |
| 8070 PrintObject(fun); | 8070 PrintObject(fun); |
| 8071 } | 8071 } |
| 8072 // function arguments | 8072 // function arguments |
| 8073 // (we are intentionally only printing the actually | 8073 // (we are intentionally only printing the actually |
| 8074 // supplied parameters, not all parameters required) | 8074 // supplied parameters, not all parameters required) |
| 8075 PrintF("(this="); | 8075 PrintF("(this="); |
| 8076 PrintObject(frame->receiver()); | 8076 PrintObject(frame->receiver()); |
| 8077 const int length = frame->GetProvidedParametersCount(); | 8077 const int length = frame->ComputeParametersCount(); |
| 8078 for (int i = 0; i < length; i++) { | 8078 for (int i = 0; i < length; i++) { |
| 8079 PrintF(", "); | 8079 PrintF(", "); |
| 8080 PrintObject(frame->GetParameter(i)); | 8080 PrintObject(frame->GetParameter(i)); |
| 8081 } | 8081 } |
| 8082 PrintF(") {\n"); | 8082 PrintF(") {\n"); |
| 8083 | 8083 |
| 8084 } else { | 8084 } else { |
| 8085 // function result | 8085 // function result |
| 8086 PrintF("} -> "); | 8086 PrintF("} -> "); |
| 8087 PrintObject(result); | 8087 PrintObject(result); |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8693 if (index < range) { | 8693 if (index < range) { |
| 8694 indices->Add(index); | 8694 indices->Add(index); |
| 8695 } | 8695 } |
| 8696 } | 8696 } |
| 8697 } | 8697 } |
| 8698 break; | 8698 break; |
| 8699 } | 8699 } |
| 8700 default: { | 8700 default: { |
| 8701 int dense_elements_length; | 8701 int dense_elements_length; |
| 8702 switch (kind) { | 8702 switch (kind) { |
| 8703 case JSObject::PIXEL_ELEMENTS: { | 8703 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { |
| 8704 dense_elements_length = | 8704 dense_elements_length = |
| 8705 PixelArray::cast(object->elements())->length(); | 8705 ExternalPixelArray::cast(object->elements())->length(); |
| 8706 break; | 8706 break; |
| 8707 } | 8707 } |
| 8708 case JSObject::EXTERNAL_BYTE_ELEMENTS: { | 8708 case JSObject::EXTERNAL_BYTE_ELEMENTS: { |
| 8709 dense_elements_length = | 8709 dense_elements_length = |
| 8710 ExternalByteArray::cast(object->elements())->length(); | 8710 ExternalByteArray::cast(object->elements())->length(); |
| 8711 break; | 8711 break; |
| 8712 } | 8712 } |
| 8713 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { | 8713 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 8714 dense_elements_length = | 8714 dense_elements_length = |
| 8715 ExternalUnsignedByteArray::cast(object->elements())->length(); | 8715 ExternalUnsignedByteArray::cast(object->elements())->length(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8820 Handle<Object> element = GetElement(receiver, index); | 8820 Handle<Object> element = GetElement(receiver, index); |
| 8821 if (element.is_null()) return false; | 8821 if (element.is_null()) return false; |
| 8822 visitor->visit(index, element); | 8822 visitor->visit(index, element); |
| 8823 // Skip to next different index (i.e., omit duplicates). | 8823 // Skip to next different index (i.e., omit duplicates). |
| 8824 do { | 8824 do { |
| 8825 j++; | 8825 j++; |
| 8826 } while (j < n && indices[j] == index); | 8826 } while (j < n && indices[j] == index); |
| 8827 } | 8827 } |
| 8828 break; | 8828 break; |
| 8829 } | 8829 } |
| 8830 case JSObject::PIXEL_ELEMENTS: { | 8830 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { |
| 8831 Handle<PixelArray> pixels(PixelArray::cast(receiver->elements())); | 8831 Handle<ExternalPixelArray> pixels(ExternalPixelArray::cast( |
| 8832 receiver->elements())); |
| 8832 for (uint32_t j = 0; j < length; j++) { | 8833 for (uint32_t j = 0; j < length; j++) { |
| 8833 Handle<Smi> e(Smi::FromInt(pixels->get(j))); | 8834 Handle<Smi> e(Smi::FromInt(pixels->get(j))); |
| 8834 visitor->visit(j, e); | 8835 visitor->visit(j, e); |
| 8835 } | 8836 } |
| 8836 break; | 8837 break; |
| 8837 } | 8838 } |
| 8838 case JSObject::EXTERNAL_BYTE_ELEMENTS: { | 8839 case JSObject::EXTERNAL_BYTE_ELEMENTS: { |
| 8839 IterateExternalArrayElements<ExternalByteArray, int8_t>( | 8840 IterateExternalArrayElements<ExternalByteArray, int8_t>( |
| 8840 isolate, receiver, true, true, visitor); | 8841 isolate, receiver, true, true, visitor); |
| 8841 break; | 8842 break; |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9659 | 9660 |
| 9660 // Now advance to the arguments adapter frame (if any). It contains all | 9661 // Now advance to the arguments adapter frame (if any). It contains all |
| 9661 // the provided parameters whereas the function frame always have the number | 9662 // the provided parameters whereas the function frame always have the number |
| 9662 // of arguments matching the functions parameters. The rest of the | 9663 // of arguments matching the functions parameters. The rest of the |
| 9663 // information (except for what is collected above) is the same. | 9664 // information (except for what is collected above) is the same. |
| 9664 it.AdvanceToArgumentsFrame(); | 9665 it.AdvanceToArgumentsFrame(); |
| 9665 | 9666 |
| 9666 // Find the number of arguments to fill. At least fill the number of | 9667 // Find the number of arguments to fill. At least fill the number of |
| 9667 // parameters for the function and fill more if more parameters are provided. | 9668 // parameters for the function and fill more if more parameters are provided. |
| 9668 int argument_count = info.number_of_parameters(); | 9669 int argument_count = info.number_of_parameters(); |
| 9669 if (argument_count < it.frame()->GetProvidedParametersCount()) { | 9670 if (argument_count < it.frame()->ComputeParametersCount()) { |
| 9670 argument_count = it.frame()->GetProvidedParametersCount(); | 9671 argument_count = it.frame()->ComputeParametersCount(); |
| 9671 } | 9672 } |
| 9672 | 9673 |
| 9673 // Calculate the size of the result. | 9674 // Calculate the size of the result. |
| 9674 int details_size = kFrameDetailsFirstDynamicIndex + | 9675 int details_size = kFrameDetailsFirstDynamicIndex + |
| 9675 2 * (argument_count + info.NumberOfLocals()) + | 9676 2 * (argument_count + info.NumberOfLocals()) + |
| 9676 (at_return ? 1 : 0); | 9677 (at_return ? 1 : 0); |
| 9677 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); | 9678 Handle<FixedArray> details = isolate->factory()->NewFixedArray(details_size); |
| 9678 | 9679 |
| 9679 // Add the frame id. | 9680 // Add the frame id. |
| 9680 details->set(kFrameDetailsFrameIdIndex, *frame_id); | 9681 details->set(kFrameDetailsFrameIdIndex, *frame_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9718 } else { | 9719 } else { |
| 9719 details->set(details_index++, heap->undefined_value()); | 9720 details->set(details_index++, heap->undefined_value()); |
| 9720 } | 9721 } |
| 9721 | 9722 |
| 9722 // Parameter value. If we are inspecting an optimized frame, use | 9723 // Parameter value. If we are inspecting an optimized frame, use |
| 9723 // undefined as the value. | 9724 // undefined as the value. |
| 9724 // | 9725 // |
| 9725 // TODO(3141533): We should be able to get the actual parameter | 9726 // TODO(3141533): We should be able to get the actual parameter |
| 9726 // value for optimized frames. | 9727 // value for optimized frames. |
| 9727 if (!is_optimized_frame && | 9728 if (!is_optimized_frame && |
| 9728 (i < it.frame()->GetProvidedParametersCount())) { | 9729 (i < it.frame()->ComputeParametersCount())) { |
| 9729 details->set(details_index++, it.frame()->GetParameter(i)); | 9730 details->set(details_index++, it.frame()->GetParameter(i)); |
| 9730 } else { | 9731 } else { |
| 9731 details->set(details_index++, heap->undefined_value()); | 9732 details->set(details_index++, heap->undefined_value()); |
| 9732 } | 9733 } |
| 9733 } | 9734 } |
| 9734 | 9735 |
| 9735 // Add locals name and value from the temporary copy from the function frame. | 9736 // Add locals name and value from the temporary copy from the function frame. |
| 9736 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { | 9737 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { |
| 9737 details->set(details_index++, locals->get(i)); | 9738 details->set(details_index++, locals->get(i)); |
| 9738 } | 9739 } |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10639 } | 10640 } |
| 10640 | 10641 |
| 10641 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { | 10642 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { |
| 10642 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), | 10643 index = scope_info->ContextSlotIndex(isolate->heap()->arguments_symbol(), |
| 10643 NULL); | 10644 NULL); |
| 10644 if (index != -1) { | 10645 if (index != -1) { |
| 10645 return Handle<Object>(function_context->get(index), isolate); | 10646 return Handle<Object>(function_context->get(index), isolate); |
| 10646 } | 10647 } |
| 10647 } | 10648 } |
| 10648 | 10649 |
| 10649 const int length = frame->GetProvidedParametersCount(); | 10650 const int length = frame->ComputeParametersCount(); |
| 10650 Handle<JSObject> arguments = | 10651 Handle<JSObject> arguments = |
| 10651 isolate->factory()->NewArgumentsObject(function, length); | 10652 isolate->factory()->NewArgumentsObject(function, length); |
| 10652 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); | 10653 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); |
| 10653 | 10654 |
| 10654 AssertNoAllocation no_gc; | 10655 AssertNoAllocation no_gc; |
| 10655 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 10656 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 10656 for (int i = 0; i < length; i++) { | 10657 for (int i = 0; i < length; i++) { |
| 10657 array->set(i, frame->GetParameter(i), mode); | 10658 array->set(i, frame->GetParameter(i), mode); |
| 10658 } | 10659 } |
| 10659 arguments->set_elements(*array); | 10660 arguments->set_elements(*array); |
| (...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12163 } else { | 12164 } else { |
| 12164 // Handle last resort GC and make sure to allow future allocations | 12165 // Handle last resort GC and make sure to allow future allocations |
| 12165 // to grow the heap without causing GCs (if possible). | 12166 // to grow the heap without causing GCs (if possible). |
| 12166 COUNTERS->gc_last_resort_from_js()->Increment(); | 12167 COUNTERS->gc_last_resort_from_js()->Increment(); |
| 12167 HEAP->CollectAllGarbage(false); | 12168 HEAP->CollectAllGarbage(false); |
| 12168 } | 12169 } |
| 12169 } | 12170 } |
| 12170 | 12171 |
| 12171 | 12172 |
| 12172 } } // namespace v8::internal | 12173 } } // namespace v8::internal |
| OLD | NEW |