OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 4485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4496 } | 4496 } |
4497 | 4497 |
4498 | 4498 |
4499 static Object* Runtime_Break(Arguments args) { | 4499 static Object* Runtime_Break(Arguments args) { |
4500 ASSERT(args.length() == 0); | 4500 ASSERT(args.length() == 0); |
4501 StackGuard::DebugBreak(); | 4501 StackGuard::DebugBreak(); |
4502 return Heap::undefined_value(); | 4502 return Heap::undefined_value(); |
4503 } | 4503 } |
4504 | 4504 |
4505 | 4505 |
4506 static Object* DebugLookupResultValue(LookupResult* result) { | 4506 static Object* DebugLookupResultValue(Object* obj, String* name, |
4507 Object* value; | 4507 LookupResult* result, |
| 4508 bool* caught_exception) { |
4508 switch (result->type()) { | 4509 switch (result->type()) { |
4509 case NORMAL: { | 4510 case NORMAL: |
4510 Dictionary* dict = | 4511 case FIELD: |
4511 JSObject::cast(result->holder())->property_dictionary(); | 4512 case CONSTANT_FUNCTION: |
4512 value = dict->ValueAt(result->GetDictionaryEntry()); | 4513 return obj->GetProperty(name); |
4513 if (value->IsTheHole()) { | 4514 case CALLBACKS: { |
4514 return Heap::undefined_value(); | 4515 // Get the property value. If there is an exception it must be thown from |
| 4516 // a JavaScript getter. |
| 4517 Object* value; |
| 4518 value = obj->GetProperty(name); |
| 4519 if (value->IsException()) { |
| 4520 if (caught_exception != NULL) { |
| 4521 *caught_exception = true; |
| 4522 } |
| 4523 value = Top::pending_exception(); |
| 4524 Top::optional_reschedule_exception(true); |
4515 } | 4525 } |
| 4526 ASSERT(!Top::has_pending_exception()); |
| 4527 ASSERT(!Top::external_caught_exception()); |
4516 return value; | 4528 return value; |
4517 } | 4529 } |
4518 case FIELD: | |
4519 value = | |
4520 JSObject::cast( | |
4521 result->holder())->FastPropertyAt(result->GetFieldIndex()); | |
4522 if (value->IsTheHole()) { | |
4523 return Heap::undefined_value(); | |
4524 } | |
4525 return value; | |
4526 case CONSTANT_FUNCTION: | |
4527 return result->GetConstantFunction(); | |
4528 case CALLBACKS: | |
4529 case INTERCEPTOR: | 4530 case INTERCEPTOR: |
| 4531 return obj->GetProperty(name); |
4530 case MAP_TRANSITION: | 4532 case MAP_TRANSITION: |
4531 case CONSTANT_TRANSITION: | 4533 case CONSTANT_TRANSITION: |
4532 case NULL_DESCRIPTOR: | 4534 case NULL_DESCRIPTOR: |
4533 return Heap::undefined_value(); | 4535 return Heap::undefined_value(); |
4534 default: | 4536 default: |
4535 UNREACHABLE(); | 4537 UNREACHABLE(); |
4536 } | 4538 } |
4537 UNREACHABLE(); | 4539 UNREACHABLE(); |
4538 return Heap::undefined_value(); | 4540 return Heap::undefined_value(); |
4539 } | 4541 } |
4540 | 4542 |
4541 | 4543 |
| 4544 // Get debugger related details for an object property. |
| 4545 // args[0]: object holding property |
| 4546 // args[1]: name of the property |
| 4547 // |
| 4548 // The array returned contains the following information: |
| 4549 // 0: Property value |
| 4550 // 1: Property details |
| 4551 // 2: Property value is exception |
| 4552 // 3: Getter function if defined |
| 4553 // 4: Setter function if defined |
| 4554 // Items 2-4 are only filled if the property has either a getter or a setter |
| 4555 // defined through __defineGetter__ and/or __defineSetter__. |
4542 static Object* Runtime_DebugGetPropertyDetails(Arguments args) { | 4556 static Object* Runtime_DebugGetPropertyDetails(Arguments args) { |
4543 HandleScope scope; | 4557 HandleScope scope; |
4544 | 4558 |
4545 ASSERT(args.length() == 2); | 4559 ASSERT(args.length() == 2); |
4546 | 4560 |
4547 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4561 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4548 CONVERT_ARG_CHECKED(String, name, 1); | 4562 CONVERT_ARG_CHECKED(String, name, 1); |
4549 | 4563 |
4550 // Check if the name is trivially convertible to an index and get the element | 4564 // Check if the name is trivially convertible to an index and get the element |
4551 // if so. | 4565 // if so. |
4552 uint32_t index; | 4566 uint32_t index; |
4553 if (name->AsArrayIndex(&index)) { | 4567 if (name->AsArrayIndex(&index)) { |
4554 Handle<FixedArray> details = Factory::NewFixedArray(2); | 4568 Handle<FixedArray> details = Factory::NewFixedArray(2); |
4555 details->set(0, Runtime::GetElementOrCharAt(obj, index)); | 4569 details->set(0, Runtime::GetElementOrCharAt(obj, index)); |
4556 details->set(1, PropertyDetails(NONE, NORMAL).AsSmi()); | 4570 details->set(1, PropertyDetails(NONE, NORMAL).AsSmi()); |
4557 return *Factory::NewJSArrayWithElements(details); | 4571 return *Factory::NewJSArrayWithElements(details); |
4558 } | 4572 } |
4559 | 4573 |
4560 // Perform standard local lookup on the object. | 4574 // Perform standard local lookup on the object. |
4561 LookupResult result; | 4575 LookupResult result; |
4562 obj->Lookup(*name, &result); | 4576 obj->LocalLookup(*name, &result); |
4563 if (result.IsProperty()) { | 4577 if (result.IsProperty()) { |
4564 Handle<Object> value(DebugLookupResultValue(&result)); | 4578 bool caught_exception = false; |
4565 Handle<FixedArray> details = Factory::NewFixedArray(2); | 4579 Handle<Object> value(DebugLookupResultValue(*obj, *name, &result, |
| 4580 &caught_exception)); |
| 4581 // If the callback object is a fixed array then it contains JavaScript |
| 4582 // getter and/or setter. |
| 4583 bool hasJavaScriptAccessors = result.type() == CALLBACKS && |
| 4584 result.GetCallbackObject()->IsFixedArray(); |
| 4585 Handle<FixedArray> details = |
| 4586 Factory::NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
4566 details->set(0, *value); | 4587 details->set(0, *value); |
4567 details->set(1, result.GetPropertyDetails().AsSmi()); | 4588 details->set(1, result.GetPropertyDetails().AsSmi()); |
| 4589 if (hasJavaScriptAccessors) { |
| 4590 details->set(2, |
| 4591 caught_exception ? Heap::true_value() : Heap::false_value()); |
| 4592 details->set(3, FixedArray::cast(result.GetCallbackObject())->get(0)); |
| 4593 details->set(4, FixedArray::cast(result.GetCallbackObject())->get(1)); |
| 4594 } |
| 4595 |
4568 return *Factory::NewJSArrayWithElements(details); | 4596 return *Factory::NewJSArrayWithElements(details); |
4569 } | 4597 } |
4570 return Heap::undefined_value(); | 4598 return Heap::undefined_value(); |
4571 } | 4599 } |
4572 | 4600 |
4573 | 4601 |
4574 static Object* Runtime_DebugGetProperty(Arguments args) { | 4602 static Object* Runtime_DebugGetProperty(Arguments args) { |
4575 HandleScope scope; | 4603 HandleScope scope; |
4576 | 4604 |
4577 ASSERT(args.length() == 2); | 4605 ASSERT(args.length() == 2); |
4578 | 4606 |
4579 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4607 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4580 CONVERT_ARG_CHECKED(String, name, 1); | 4608 CONVERT_ARG_CHECKED(String, name, 1); |
4581 | 4609 |
4582 LookupResult result; | 4610 LookupResult result; |
4583 obj->Lookup(*name, &result); | 4611 obj->Lookup(*name, &result); |
4584 if (result.IsProperty()) { | 4612 if (result.IsProperty()) { |
4585 return DebugLookupResultValue(&result); | 4613 return DebugLookupResultValue(*obj, *name, &result, NULL); |
4586 } | 4614 } |
4587 return Heap::undefined_value(); | 4615 return Heap::undefined_value(); |
4588 } | 4616 } |
4589 | 4617 |
4590 | 4618 |
4591 // Return the names of the local named properties. | 4619 // Return the names of the local named properties. |
4592 // args[0]: object | 4620 // args[0]: object |
4593 static Object* Runtime_DebugLocalPropertyNames(Arguments args) { | 4621 static Object* Runtime_DebugLocalPropertyNames(Arguments args) { |
4594 HandleScope scope; | 4622 HandleScope scope; |
4595 ASSERT(args.length() == 1); | 4623 ASSERT(args.length() == 1); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4669 return Smi::FromInt(result); | 4697 return Smi::FromInt(result); |
4670 } | 4698 } |
4671 | 4699 |
4672 | 4700 |
4673 // Return property names from named interceptor. | 4701 // Return property names from named interceptor. |
4674 // args[0]: object | 4702 // args[0]: object |
4675 static Object* Runtime_DebugNamedInterceptorPropertyNames(Arguments args) { | 4703 static Object* Runtime_DebugNamedInterceptorPropertyNames(Arguments args) { |
4676 HandleScope scope; | 4704 HandleScope scope; |
4677 ASSERT(args.length() == 1); | 4705 ASSERT(args.length() == 1); |
4678 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4706 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4679 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | |
4680 | 4707 |
4681 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj); | 4708 if (obj->HasNamedInterceptor()) { |
4682 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 4709 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj); |
| 4710 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
| 4711 } |
4683 return Heap::undefined_value(); | 4712 return Heap::undefined_value(); |
4684 } | 4713 } |
4685 | 4714 |
4686 | 4715 |
4687 // Return element names from indexed interceptor. | 4716 // Return element names from indexed interceptor. |
4688 // args[0]: object | 4717 // args[0]: object |
4689 static Object* Runtime_DebugIndexedInterceptorElementNames(Arguments args) { | 4718 static Object* Runtime_DebugIndexedInterceptorElementNames(Arguments args) { |
4690 HandleScope scope; | 4719 HandleScope scope; |
4691 ASSERT(args.length() == 1); | 4720 ASSERT(args.length() == 1); |
4692 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4721 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4693 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | |
4694 | 4722 |
4695 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); | 4723 if (obj->HasIndexedInterceptor()) { |
4696 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 4724 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); |
| 4725 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
| 4726 } |
4697 return Heap::undefined_value(); | 4727 return Heap::undefined_value(); |
4698 } | 4728 } |
4699 | 4729 |
4700 | 4730 |
4701 // Return property value from named interceptor. | 4731 // Return property value from named interceptor. |
4702 // args[0]: object | 4732 // args[0]: object |
4703 // args[1]: property name | 4733 // args[1]: property name |
4704 static Object* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) { | 4734 static Object* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) { |
4705 HandleScope scope; | 4735 HandleScope scope; |
4706 ASSERT(args.length() == 2); | 4736 ASSERT(args.length() == 2); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5898 } else { | 5928 } else { |
5899 // Handle last resort GC and make sure to allow future allocations | 5929 // Handle last resort GC and make sure to allow future allocations |
5900 // to grow the heap without causing GCs (if possible). | 5930 // to grow the heap without causing GCs (if possible). |
5901 Counters::gc_last_resort_from_js.Increment(); | 5931 Counters::gc_last_resort_from_js.Increment(); |
5902 Heap::CollectAllGarbage(); | 5932 Heap::CollectAllGarbage(); |
5903 } | 5933 } |
5904 } | 5934 } |
5905 | 5935 |
5906 | 5936 |
5907 } } // namespace v8::internal | 5937 } } // namespace v8::internal |
OLD | NEW |