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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 elms->set(WRITABLE_INDEX, Heap::false_value()); | 782 elms->set(WRITABLE_INDEX, Heap::false_value()); |
783 elms->set(ENUMERABLE_INDEX, Heap::false_value()); | 783 elms->set(ENUMERABLE_INDEX, Heap::false_value()); |
784 elms->set(CONFIGURABLE_INDEX, Heap::false_value()); | 784 elms->set(CONFIGURABLE_INDEX, Heap::false_value()); |
785 return *desc; | 785 return *desc; |
786 } | 786 } |
787 | 787 |
788 case JSObject::INTERCEPTED_ELEMENT: | 788 case JSObject::INTERCEPTED_ELEMENT: |
789 case JSObject::FAST_ELEMENT: { | 789 case JSObject::FAST_ELEMENT: { |
790 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); | 790 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
791 Handle<Object> value = GetElement(obj, index); | 791 Handle<Object> value = GetElement(obj, index); |
| 792 RETURN_IF_EMPTY_HANDLE(value); |
792 elms->set(VALUE_INDEX, *value); | 793 elms->set(VALUE_INDEX, *value); |
793 elms->set(WRITABLE_INDEX, Heap::true_value()); | 794 elms->set(WRITABLE_INDEX, Heap::true_value()); |
794 elms->set(ENUMERABLE_INDEX, Heap::true_value()); | 795 elms->set(ENUMERABLE_INDEX, Heap::true_value()); |
795 elms->set(CONFIGURABLE_INDEX, Heap::true_value()); | 796 elms->set(CONFIGURABLE_INDEX, Heap::true_value()); |
796 return *desc; | 797 return *desc; |
797 } | 798 } |
798 | 799 |
799 case JSObject::DICTIONARY_ELEMENT: { | 800 case JSObject::DICTIONARY_ELEMENT: { |
800 Handle<JSObject> holder = obj; | 801 Handle<JSObject> holder = obj; |
801 if (obj->IsJSGlobalProxy()) { | 802 if (obj->IsJSGlobalProxy()) { |
(...skipping 17 matching lines...) Expand all Loading... |
819 } | 820 } |
820 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { | 821 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { |
821 elms->set(SETTER_INDEX, callbacks->get(1)); | 822 elms->set(SETTER_INDEX, callbacks->get(1)); |
822 } | 823 } |
823 break; | 824 break; |
824 } | 825 } |
825 case NORMAL: { | 826 case NORMAL: { |
826 // This is a data property. | 827 // This is a data property. |
827 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); | 828 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
828 Handle<Object> value = GetElement(obj, index); | 829 Handle<Object> value = GetElement(obj, index); |
| 830 ASSERT(!value.is_null()); |
829 elms->set(VALUE_INDEX, *value); | 831 elms->set(VALUE_INDEX, *value); |
830 elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly())); | 832 elms->set(WRITABLE_INDEX, Heap::ToBoolean(!details.IsReadOnly())); |
831 break; | 833 break; |
832 } | 834 } |
833 default: | 835 default: |
834 UNREACHABLE(); | 836 UNREACHABLE(); |
835 break; | 837 break; |
836 } | 838 } |
837 elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!details.IsDontEnum())); | 839 elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!details.IsDontEnum())); |
838 elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!details.IsDontDelete())); | 840 elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!details.IsDontDelete())); |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 // should have been a const redeclaration error when declaring | 1464 // should have been a const redeclaration error when declaring |
1463 // the const property. | 1465 // the const property. |
1464 ASSERT(!holder.is_identical_to(context)); | 1466 ASSERT(!holder.is_identical_to(context)); |
1465 if ((attributes & READ_ONLY) == 0) { | 1467 if ((attributes & READ_ONLY) == 0) { |
1466 Handle<Context>::cast(holder)->set(index, *value); | 1468 Handle<Context>::cast(holder)->set(index, *value); |
1467 } | 1469 } |
1468 } else { | 1470 } else { |
1469 // The holder is an arguments object. | 1471 // The holder is an arguments object. |
1470 ASSERT((attributes & READ_ONLY) == 0); | 1472 ASSERT((attributes & READ_ONLY) == 0); |
1471 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); | 1473 Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
1472 SetElement(arguments, index, value); | 1474 RETURN_IF_EMPTY_HANDLE(SetElement(arguments, index, value)); |
1473 } | 1475 } |
1474 return *value; | 1476 return *value; |
1475 } | 1477 } |
1476 | 1478 |
1477 // The property could not be found, we introduce it in the global | 1479 // The property could not be found, we introduce it in the global |
1478 // context. | 1480 // context. |
1479 if (attributes == ABSENT) { | 1481 if (attributes == ABSENT) { |
1480 Handle<JSObject> global = Handle<JSObject>(Top::context()->global()); | 1482 Handle<JSObject> global = Handle<JSObject>(Top::context()->global()); |
1481 // Strict mode not needed (const disallowed in strict mode). | 1483 // Strict mode not needed (const disallowed in strict mode). |
1482 RETURN_IF_EMPTY_HANDLE( | 1484 RETURN_IF_EMPTY_HANDLE( |
(...skipping 6894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8377 | 8379 |
8378 | 8380 |
8379 /** | 8381 /** |
8380 * A helper function that visits elements of a JSArray in numerical | 8382 * A helper function that visits elements of a JSArray in numerical |
8381 * order. | 8383 * order. |
8382 * | 8384 * |
8383 * The visitor argument called for each existing element in the array | 8385 * The visitor argument called for each existing element in the array |
8384 * with the element index and the element's value. | 8386 * with the element index and the element's value. |
8385 * Afterwards it increments the base-index of the visitor by the array | 8387 * Afterwards it increments the base-index of the visitor by the array |
8386 * length. | 8388 * length. |
| 8389 * Returns false if any access threw an exception, otherwise true. |
8387 */ | 8390 */ |
8388 static void IterateElements(Handle<JSArray> receiver, | 8391 static bool IterateElements(Handle<JSArray> receiver, |
8389 ArrayConcatVisitor* visitor) { | 8392 ArrayConcatVisitor* visitor) { |
8390 uint32_t length = static_cast<uint32_t>(receiver->length()->Number()); | 8393 uint32_t length = static_cast<uint32_t>(receiver->length()->Number()); |
8391 switch (receiver->GetElementsKind()) { | 8394 switch (receiver->GetElementsKind()) { |
8392 case JSObject::FAST_ELEMENTS: { | 8395 case JSObject::FAST_ELEMENTS: { |
8393 // Run through the elements FixedArray and use HasElement and GetElement | 8396 // Run through the elements FixedArray and use HasElement and GetElement |
8394 // to check the prototype for missing elements. | 8397 // to check the prototype for missing elements. |
8395 Handle<FixedArray> elements(FixedArray::cast(receiver->elements())); | 8398 Handle<FixedArray> elements(FixedArray::cast(receiver->elements())); |
8396 int fast_length = static_cast<int>(length); | 8399 int fast_length = static_cast<int>(length); |
8397 ASSERT(fast_length <= elements->length()); | 8400 ASSERT(fast_length <= elements->length()); |
8398 for (int j = 0; j < fast_length; j++) { | 8401 for (int j = 0; j < fast_length; j++) { |
8399 HandleScope loop_scope; | 8402 HandleScope loop_scope; |
8400 Handle<Object> element_value(elements->get(j)); | 8403 Handle<Object> element_value(elements->get(j)); |
8401 if (!element_value->IsTheHole()) { | 8404 if (!element_value->IsTheHole()) { |
8402 visitor->visit(j, element_value); | 8405 visitor->visit(j, element_value); |
8403 } else if (receiver->HasElement(j)) { | 8406 } else if (receiver->HasElement(j)) { |
8404 // Call GetElement on receiver, not its prototype, or getters won't | 8407 // Call GetElement on receiver, not its prototype, or getters won't |
8405 // have the correct receiver. | 8408 // have the correct receiver. |
8406 element_value = GetElement(receiver, j); | 8409 element_value = GetElement(receiver, j); |
| 8410 if (element_value.is_null()) return false; |
8407 visitor->visit(j, element_value); | 8411 visitor->visit(j, element_value); |
8408 } | 8412 } |
8409 } | 8413 } |
8410 break; | 8414 break; |
8411 } | 8415 } |
8412 case JSObject::DICTIONARY_ELEMENTS: { | 8416 case JSObject::DICTIONARY_ELEMENTS: { |
8413 Handle<NumberDictionary> dict(receiver->element_dictionary()); | 8417 Handle<NumberDictionary> dict(receiver->element_dictionary()); |
8414 List<uint32_t> indices(dict->Capacity() / 2); | 8418 List<uint32_t> indices(dict->Capacity() / 2); |
8415 // Collect all indices in the object and the prototypes less | 8419 // Collect all indices in the object and the prototypes less |
8416 // than length. This might introduce duplicates in the indices list. | 8420 // than length. This might introduce duplicates in the indices list. |
8417 CollectElementIndices(receiver, length, &indices); | 8421 CollectElementIndices(receiver, length, &indices); |
8418 indices.Sort(&compareUInt32); | 8422 indices.Sort(&compareUInt32); |
8419 int j = 0; | 8423 int j = 0; |
8420 int n = indices.length(); | 8424 int n = indices.length(); |
8421 while (j < n) { | 8425 while (j < n) { |
8422 HandleScope loop_scope; | 8426 HandleScope loop_scope; |
8423 uint32_t index = indices[j]; | 8427 uint32_t index = indices[j]; |
8424 Handle<Object> element = GetElement(receiver, index); | 8428 Handle<Object> element = GetElement(receiver, index); |
| 8429 if (element.is_null()) return false; |
8425 visitor->visit(index, element); | 8430 visitor->visit(index, element); |
8426 // Skip to next different index (i.e., omit duplicates). | 8431 // Skip to next different index (i.e., omit duplicates). |
8427 do { | 8432 do { |
8428 j++; | 8433 j++; |
8429 } while (j < n && indices[j] == index); | 8434 } while (j < n && indices[j] == index); |
8430 } | 8435 } |
8431 break; | 8436 break; |
8432 } | 8437 } |
8433 case JSObject::PIXEL_ELEMENTS: { | 8438 case JSObject::PIXEL_ELEMENTS: { |
8434 Handle<PixelArray> pixels(PixelArray::cast(receiver->elements())); | 8439 Handle<PixelArray> pixels(PixelArray::cast(receiver->elements())); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8471 case JSObject::EXTERNAL_FLOAT_ELEMENTS: { | 8476 case JSObject::EXTERNAL_FLOAT_ELEMENTS: { |
8472 IterateExternalArrayElements<ExternalFloatArray, float>( | 8477 IterateExternalArrayElements<ExternalFloatArray, float>( |
8473 receiver, false, false, visitor); | 8478 receiver, false, false, visitor); |
8474 break; | 8479 break; |
8475 } | 8480 } |
8476 default: | 8481 default: |
8477 UNREACHABLE(); | 8482 UNREACHABLE(); |
8478 break; | 8483 break; |
8479 } | 8484 } |
8480 visitor->increase_index_offset(length); | 8485 visitor->increase_index_offset(length); |
| 8486 return true; |
8481 } | 8487 } |
8482 | 8488 |
8483 | 8489 |
8484 /** | 8490 /** |
8485 * Array::concat implementation. | 8491 * Array::concat implementation. |
8486 * See ECMAScript 262, 15.4.4.4. | 8492 * See ECMAScript 262, 15.4.4.4. |
8487 * TODO(581): Fix non-compliance for very large concatenations and update to | 8493 * TODO(581): Fix non-compliance for very large concatenations and update to |
8488 * following the ECMAScript 5 specification. | 8494 * following the ECMAScript 5 specification. |
8489 */ | 8495 */ |
8490 static MaybeObject* Runtime_ArrayConcat(Arguments args) { | 8496 static MaybeObject* Runtime_ArrayConcat(Arguments args) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8552 storage = Handle<FixedArray>::cast( | 8558 storage = Handle<FixedArray>::cast( |
8553 Factory::NewNumberDictionary(at_least_space_for)); | 8559 Factory::NewNumberDictionary(at_least_space_for)); |
8554 } | 8560 } |
8555 | 8561 |
8556 ArrayConcatVisitor visitor(storage, fast_case); | 8562 ArrayConcatVisitor visitor(storage, fast_case); |
8557 | 8563 |
8558 for (int i = 0; i < argument_count; i++) { | 8564 for (int i = 0; i < argument_count; i++) { |
8559 Handle<Object> obj(elements->get(i)); | 8565 Handle<Object> obj(elements->get(i)); |
8560 if (obj->IsJSArray()) { | 8566 if (obj->IsJSArray()) { |
8561 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 8567 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
8562 IterateElements(array, &visitor); | 8568 if (!IterateElements(array, &visitor)) { |
| 8569 return Failure::Exception(); |
| 8570 } |
8563 } else { | 8571 } else { |
8564 visitor.visit(0, obj); | 8572 visitor.visit(0, obj); |
8565 visitor.increase_index_offset(1); | 8573 visitor.increase_index_offset(1); |
8566 } | 8574 } |
8567 } | 8575 } |
8568 | 8576 |
8569 return *visitor.ToArray(); | 8577 return *visitor.ToArray(); |
8570 } | 8578 } |
8571 | 8579 |
8572 | 8580 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8650 Handle<Object> key2 = args.at<Object>(2); | 8658 Handle<Object> key2 = args.at<Object>(2); |
8651 | 8659 |
8652 uint32_t index1, index2; | 8660 uint32_t index1, index2; |
8653 if (!key1->ToArrayIndex(&index1) | 8661 if (!key1->ToArrayIndex(&index1) |
8654 || !key2->ToArrayIndex(&index2)) { | 8662 || !key2->ToArrayIndex(&index2)) { |
8655 return Top::ThrowIllegalOperation(); | 8663 return Top::ThrowIllegalOperation(); |
8656 } | 8664 } |
8657 | 8665 |
8658 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); | 8666 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); |
8659 Handle<Object> tmp1 = GetElement(jsobject, index1); | 8667 Handle<Object> tmp1 = GetElement(jsobject, index1); |
| 8668 RETURN_IF_EMPTY_HANDLE(tmp1); |
8660 Handle<Object> tmp2 = GetElement(jsobject, index2); | 8669 Handle<Object> tmp2 = GetElement(jsobject, index2); |
| 8670 RETURN_IF_EMPTY_HANDLE(tmp2); |
8661 | 8671 |
8662 SetElement(jsobject, index1, tmp2); | 8672 RETURN_IF_EMPTY_HANDLE(SetElement(jsobject, index1, tmp2)); |
8663 SetElement(jsobject, index2, tmp1); | 8673 RETURN_IF_EMPTY_HANDLE(SetElement(jsobject, index2, tmp1)); |
8664 | 8674 |
8665 return Heap::undefined_value(); | 8675 return Heap::undefined_value(); |
8666 } | 8676 } |
8667 | 8677 |
8668 | 8678 |
8669 // Returns an array that tells you where in the [0, length) interval an array | 8679 // Returns an array that tells you where in the [0, length) interval an array |
8670 // might have elements. Can either return keys (positive integers) or | 8680 // might have elements. Can either return keys (positive integers) or |
8671 // intervals (pair of a negative integer (-start-1) followed by a | 8681 // intervals (pair of a negative integer (-start-1) followed by a |
8672 // positive (length)) or undefined values. | 8682 // positive (length)) or undefined values. |
8673 // Intervals can span over some keys that are not in the object. | 8683 // Intervals can span over some keys that are not in the object. |
(...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11259 // native code offset. | 11269 // native code offset. |
11260 static MaybeObject* Runtime_CollectStackTrace(Arguments args) { | 11270 static MaybeObject* Runtime_CollectStackTrace(Arguments args) { |
11261 ASSERT_EQ(args.length(), 2); | 11271 ASSERT_EQ(args.length(), 2); |
11262 Handle<Object> caller = args.at<Object>(0); | 11272 Handle<Object> caller = args.at<Object>(0); |
11263 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); | 11273 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); |
11264 | 11274 |
11265 HandleScope scope; | 11275 HandleScope scope; |
11266 | 11276 |
11267 limit = Max(limit, 0); // Ensure that limit is not negative. | 11277 limit = Max(limit, 0); // Ensure that limit is not negative. |
11268 int initial_size = Min(limit, 10); | 11278 int initial_size = Min(limit, 10); |
11269 Handle<JSArray> result = Factory::NewJSArray(initial_size * 4); | 11279 Handle<FixedArray> elements = |
| 11280 Factory::NewFixedArrayWithHoles(initial_size * 4); |
11270 | 11281 |
11271 StackFrameIterator iter; | 11282 StackFrameIterator iter; |
11272 // If the caller parameter is a function we skip frames until we're | 11283 // If the caller parameter is a function we skip frames until we're |
11273 // under it before starting to collect. | 11284 // under it before starting to collect. |
11274 bool seen_caller = !caller->IsJSFunction(); | 11285 bool seen_caller = !caller->IsJSFunction(); |
11275 int cursor = 0; | 11286 int cursor = 0; |
11276 int frames_seen = 0; | 11287 int frames_seen = 0; |
11277 while (!iter.done() && frames_seen < limit) { | 11288 while (!iter.done() && frames_seen < limit) { |
11278 StackFrame* raw_frame = iter.frame(); | 11289 StackFrame* raw_frame = iter.frame(); |
11279 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) { | 11290 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) { |
11280 frames_seen++; | 11291 frames_seen++; |
11281 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 11292 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
11282 List<FrameSummary> frames(3); // Max 2 levels of inlining. | 11293 List<FrameSummary> frames(3); // Max 2 levels of inlining. |
11283 frame->Summarize(&frames); | 11294 frame->Summarize(&frames); |
11284 for (int i = frames.length() - 1; i >= 0; i--) { | 11295 for (int i = frames.length() - 1; i >= 0; i--) { |
| 11296 if (cursor + 4 > elements->length()) { |
| 11297 int new_capacity = JSObject::NewElementsCapacity(elements->length()); |
| 11298 Handle<FixedArray> new_elements = |
| 11299 Factory::NewFixedArrayWithHoles(new_capacity); |
| 11300 for (int i = 0; i < cursor; i++) { |
| 11301 new_elements->set(i, elements->get(i)); |
| 11302 } |
| 11303 elements = new_elements; |
| 11304 } |
| 11305 ASSERT(cursor + 4 <= elements->length()); |
| 11306 |
11285 Handle<Object> recv = frames[i].receiver(); | 11307 Handle<Object> recv = frames[i].receiver(); |
11286 Handle<JSFunction> fun = frames[i].function(); | 11308 Handle<JSFunction> fun = frames[i].function(); |
11287 Handle<Code> code = frames[i].code(); | 11309 Handle<Code> code = frames[i].code(); |
11288 Handle<Smi> offset(Smi::FromInt(frames[i].offset())); | 11310 Handle<Smi> offset(Smi::FromInt(frames[i].offset())); |
11289 FixedArray* elements = FixedArray::cast(result->elements()); | 11311 elements->set(cursor++, *recv); |
11290 if (cursor + 3 < elements->length()) { | 11312 elements->set(cursor++, *fun); |
11291 elements->set(cursor++, *recv); | 11313 elements->set(cursor++, *code); |
11292 elements->set(cursor++, *fun); | 11314 elements->set(cursor++, *offset); |
11293 elements->set(cursor++, *code); | |
11294 elements->set(cursor++, *offset); | |
11295 } else { | |
11296 SetElement(result, cursor++, recv); | |
11297 SetElement(result, cursor++, fun); | |
11298 SetElement(result, cursor++, code); | |
11299 SetElement(result, cursor++, offset); | |
11300 } | |
11301 } | 11315 } |
11302 } | 11316 } |
11303 iter.Advance(); | 11317 iter.Advance(); |
11304 } | 11318 } |
11305 | 11319 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
11306 result->set_length(Smi::FromInt(cursor)); | 11320 result->set_length(Smi::FromInt(cursor)); |
11307 return *result; | 11321 return *result; |
11308 } | 11322 } |
11309 | 11323 |
11310 | 11324 |
11311 // Returns V8 version as a string. | 11325 // Returns V8 version as a string. |
11312 static MaybeObject* Runtime_GetV8Version(Arguments args) { | 11326 static MaybeObject* Runtime_GetV8Version(Arguments args) { |
11313 ASSERT_EQ(args.length(), 0); | 11327 ASSERT_EQ(args.length(), 0); |
11314 | 11328 |
11315 NoHandleAllocation ha; | 11329 NoHandleAllocation ha; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11460 return message->script(); | 11474 return message->script(); |
11461 } | 11475 } |
11462 | 11476 |
11463 | 11477 |
11464 #ifdef DEBUG | 11478 #ifdef DEBUG |
11465 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 11479 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
11466 // Exclude the code in release mode. | 11480 // Exclude the code in release mode. |
11467 static MaybeObject* Runtime_ListNatives(Arguments args) { | 11481 static MaybeObject* Runtime_ListNatives(Arguments args) { |
11468 ASSERT(args.length() == 0); | 11482 ASSERT(args.length() == 0); |
11469 HandleScope scope; | 11483 HandleScope scope; |
11470 Handle<JSArray> result = Factory::NewJSArray(0); | 11484 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
| 11485 int entry_count = 0 |
| 11486 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
| 11487 INLINE_FUNCTION_LIST(COUNT_ENTRY) |
| 11488 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); |
| 11489 #undef COUNT_ENTRY |
| 11490 Handle<FixedArray> elements = Factory::NewFixedArray(entry_count); |
11471 int index = 0; | 11491 int index = 0; |
11472 bool inline_runtime_functions = false; | 11492 bool inline_runtime_functions = false; |
11473 #define ADD_ENTRY(Name, argc, ressize) \ | 11493 #define ADD_ENTRY(Name, argc, ressize) \ |
11474 { \ | 11494 { \ |
11475 HandleScope inner; \ | 11495 HandleScope inner; \ |
11476 Handle<String> name; \ | 11496 Handle<String> name; \ |
11477 /* Inline runtime functions have an underscore in front of the name. */ \ | 11497 /* Inline runtime functions have an underscore in front of the name. */ \ |
11478 if (inline_runtime_functions) { \ | 11498 if (inline_runtime_functions) { \ |
11479 name = Factory::NewStringFromAscii( \ | 11499 name = Factory::NewStringFromAscii( \ |
11480 Vector<const char>("_" #Name, StrLength("_" #Name))); \ | 11500 Vector<const char>("_" #Name, StrLength("_" #Name))); \ |
11481 } else { \ | 11501 } else { \ |
11482 name = Factory::NewStringFromAscii( \ | 11502 name = Factory::NewStringFromAscii( \ |
11483 Vector<const char>(#Name, StrLength(#Name))); \ | 11503 Vector<const char>(#Name, StrLength(#Name))); \ |
11484 } \ | 11504 } \ |
11485 Handle<JSArray> pair = Factory::NewJSArray(0); \ | 11505 Handle<FixedArray> pair_elements = Factory::NewFixedArray(2); \ |
11486 SetElement(pair, 0, name); \ | 11506 pair_elements->set(0, *name); \ |
11487 SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \ | 11507 pair_elements->set(1, Smi::FromInt(argc)); \ |
11488 SetElement(result, index++, pair); \ | 11508 Handle<JSArray> pair = Factory::NewJSArrayWithElements(pair_elements); \ |
| 11509 elements->set(index++, *pair); \ |
11489 } | 11510 } |
11490 inline_runtime_functions = false; | 11511 inline_runtime_functions = false; |
11491 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 11512 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
11492 inline_runtime_functions = true; | 11513 inline_runtime_functions = true; |
11493 INLINE_FUNCTION_LIST(ADD_ENTRY) | 11514 INLINE_FUNCTION_LIST(ADD_ENTRY) |
11494 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 11515 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
11495 #undef ADD_ENTRY | 11516 #undef ADD_ENTRY |
| 11517 ASSERT_EQ(index, entry_count); |
| 11518 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
11496 return *result; | 11519 return *result; |
11497 } | 11520 } |
11498 #endif | 11521 #endif |
11499 | 11522 |
11500 | 11523 |
11501 static MaybeObject* Runtime_Log(Arguments args) { | 11524 static MaybeObject* Runtime_Log(Arguments args) { |
11502 ASSERT(args.length() == 2); | 11525 ASSERT(args.length() == 2); |
11503 CONVERT_CHECKED(String, format, args[0]); | 11526 CONVERT_CHECKED(String, format, args[0]); |
11504 CONVERT_CHECKED(JSArray, elms, args[1]); | 11527 CONVERT_CHECKED(JSArray, elms, args[1]); |
11505 Vector<const char> chars = format->ToAsciiVector(); | 11528 Vector<const char> chars = format->ToAsciiVector(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11583 } else { | 11606 } else { |
11584 // Handle last resort GC and make sure to allow future allocations | 11607 // Handle last resort GC and make sure to allow future allocations |
11585 // to grow the heap without causing GCs (if possible). | 11608 // to grow the heap without causing GCs (if possible). |
11586 Counters::gc_last_resort_from_js.Increment(); | 11609 Counters::gc_last_resort_from_js.Increment(); |
11587 Heap::CollectAllGarbage(false); | 11610 Heap::CollectAllGarbage(false); |
11588 } | 11611 } |
11589 } | 11612 } |
11590 | 11613 |
11591 | 11614 |
11592 } } // namespace v8::internal | 11615 } } // namespace v8::internal |
OLD | NEW |