| 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 dictionary = NumberDictionary::cast(elements->get(1)); | 1050 dictionary = NumberDictionary::cast(elements->get(1)); |
| 1051 } else { | 1051 } else { |
| 1052 dictionary = NumberDictionary::cast(elements); | 1052 dictionary = NumberDictionary::cast(elements); |
| 1053 } | 1053 } |
| 1054 int entry = dictionary->FindEntry(index); | 1054 int entry = dictionary->FindEntry(index); |
| 1055 ASSERT(entry != NumberDictionary::kNotFound); | 1055 ASSERT(entry != NumberDictionary::kNotFound); |
| 1056 PropertyDetails details = dictionary->DetailsAt(entry); | 1056 PropertyDetails details = dictionary->DetailsAt(entry); |
| 1057 switch (details.type()) { | 1057 switch (details.type()) { |
| 1058 case CALLBACKS: { | 1058 case CALLBACKS: { |
| 1059 // This is an accessor property with getter and/or setter. | 1059 // This is an accessor property with getter and/or setter. |
| 1060 FixedArray* callbacks = | 1060 AccessorPair* accessors = |
| 1061 FixedArray::cast(dictionary->ValueAt(entry)); | 1061 AccessorPair::cast(dictionary->ValueAt(entry)); |
| 1062 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); | 1062 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); |
| 1063 if (CheckElementAccess(*obj, index, v8::ACCESS_GET)) { | 1063 if (CheckElementAccess(*obj, index, v8::ACCESS_GET)) { |
| 1064 elms->set(GETTER_INDEX, callbacks->get(0)); | 1064 elms->set(GETTER_INDEX, accessors->getter()); |
| 1065 } | 1065 } |
| 1066 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { | 1066 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { |
| 1067 elms->set(SETTER_INDEX, callbacks->get(1)); | 1067 elms->set(SETTER_INDEX, accessors->setter()); |
| 1068 } | 1068 } |
| 1069 break; | 1069 break; |
| 1070 } | 1070 } |
| 1071 case NORMAL: { | 1071 case NORMAL: { |
| 1072 // This is a data property. | 1072 // This is a data property. |
| 1073 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); | 1073 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); |
| 1074 Handle<Object> value = Object::GetElement(obj, index); | 1074 Handle<Object> value = Object::GetElement(obj, index); |
| 1075 ASSERT(!value.is_null()); | 1075 ASSERT(!value.is_null()); |
| 1076 elms->set(VALUE_INDEX, *value); | 1076 elms->set(VALUE_INDEX, *value); |
| 1077 elms->set(WRITABLE_INDEX, heap->ToBoolean(!details.IsReadOnly())); | 1077 elms->set(WRITABLE_INDEX, heap->ToBoolean(!details.IsReadOnly())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 if (!CheckAccess(*obj, *name, &result, v8::ACCESS_HAS)) { | 1098 if (!CheckAccess(*obj, *name, &result, v8::ACCESS_HAS)) { |
| 1099 return heap->false_value(); | 1099 return heap->false_value(); |
| 1100 } | 1100 } |
| 1101 | 1101 |
| 1102 elms->set(ENUMERABLE_INDEX, heap->ToBoolean(!result.IsDontEnum())); | 1102 elms->set(ENUMERABLE_INDEX, heap->ToBoolean(!result.IsDontEnum())); |
| 1103 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean(!result.IsDontDelete())); | 1103 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean(!result.IsDontDelete())); |
| 1104 | 1104 |
| 1105 bool is_js_accessor = (result.type() == CALLBACKS) && | 1105 bool is_js_accessor = (result.type() == CALLBACKS) && |
| 1106 (result.GetCallbackObject()->IsFixedArray()); | 1106 (result.GetCallbackObject()->IsAccessorPair()); |
| 1107 | 1107 |
| 1108 if (is_js_accessor) { | 1108 if (is_js_accessor) { |
| 1109 // __defineGetter__/__defineSetter__ callback. | 1109 // __defineGetter__/__defineSetter__ callback. |
| 1110 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); | 1110 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); |
| 1111 | 1111 |
| 1112 FixedArray* structure = FixedArray::cast(result.GetCallbackObject()); | 1112 AccessorPair* accessors = AccessorPair::cast(result.GetCallbackObject()); |
| 1113 if (CheckAccess(*obj, *name, &result, v8::ACCESS_GET)) { | 1113 if (CheckAccess(*obj, *name, &result, v8::ACCESS_GET)) { |
| 1114 elms->set(GETTER_INDEX, structure->get(0)); | 1114 elms->set(GETTER_INDEX, accessors->getter()); |
| 1115 } | 1115 } |
| 1116 if (CheckAccess(*obj, *name, &result, v8::ACCESS_SET)) { | 1116 if (CheckAccess(*obj, *name, &result, v8::ACCESS_SET)) { |
| 1117 elms->set(SETTER_INDEX, structure->get(1)); | 1117 elms->set(SETTER_INDEX, accessors->setter()); |
| 1118 } | 1118 } |
| 1119 } else { | 1119 } else { |
| 1120 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); | 1120 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); |
| 1121 elms->set(WRITABLE_INDEX, heap->ToBoolean(!result.IsReadOnly())); | 1121 elms->set(WRITABLE_INDEX, heap->ToBoolean(!result.IsReadOnly())); |
| 1122 | 1122 |
| 1123 PropertyAttributes attrs; | 1123 PropertyAttributes attrs; |
| 1124 Object* value; | 1124 Object* value; |
| 1125 // GetProperty will check access and report any violations. | 1125 // GetProperty will check access and report any violations. |
| 1126 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); | 1126 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); |
| 1127 if (!maybe_value->ToObject(&value)) return maybe_value; | 1127 if (!maybe_value->ToObject(&value)) return maybe_value; |
| (...skipping 9340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10468 { MaybeObject* maybe_raw_value = | 10468 { MaybeObject* maybe_raw_value = |
| 10469 DebugLookupResultValue(isolate->heap(), *obj, *name, | 10469 DebugLookupResultValue(isolate->heap(), *obj, *name, |
| 10470 &result, &caught_exception); | 10470 &result, &caught_exception); |
| 10471 if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value; | 10471 if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value; |
| 10472 } | 10472 } |
| 10473 Handle<Object> value(raw_value, isolate); | 10473 Handle<Object> value(raw_value, isolate); |
| 10474 | 10474 |
| 10475 // If the callback object is a fixed array then it contains JavaScript | 10475 // If the callback object is a fixed array then it contains JavaScript |
| 10476 // getter and/or setter. | 10476 // getter and/or setter. |
| 10477 bool hasJavaScriptAccessors = result_type == CALLBACKS && | 10477 bool hasJavaScriptAccessors = result_type == CALLBACKS && |
| 10478 result_callback_obj->IsFixedArray(); | 10478 result_callback_obj->IsAccessorPair(); |
| 10479 Handle<FixedArray> details = | 10479 Handle<FixedArray> details = |
| 10480 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); | 10480 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
| 10481 details->set(0, *value); | 10481 details->set(0, *value); |
| 10482 details->set(1, property_details); | 10482 details->set(1, property_details); |
| 10483 if (hasJavaScriptAccessors) { | 10483 if (hasJavaScriptAccessors) { |
| 10484 details->set(2, isolate->heap()->ToBoolean(caught_exception)); | 10484 details->set(2, isolate->heap()->ToBoolean(caught_exception)); |
| 10485 details->set(3, FixedArray::cast(*result_callback_obj)->get(0)); | 10485 details->set(3, AccessorPair::cast(*result_callback_obj)->getter()); |
| 10486 details->set(4, FixedArray::cast(*result_callback_obj)->get(1)); | 10486 details->set(4, AccessorPair::cast(*result_callback_obj)->setter()); |
| 10487 } | 10487 } |
| 10488 | 10488 |
| 10489 return *isolate->factory()->NewJSArrayWithElements(details); | 10489 return *isolate->factory()->NewJSArrayWithElements(details); |
| 10490 } | 10490 } |
| 10491 if (i < length - 1) { | 10491 if (i < length - 1) { |
| 10492 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10492 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 10493 } | 10493 } |
| 10494 } | 10494 } |
| 10495 | 10495 |
| 10496 return isolate->heap()->undefined_value(); | 10496 return isolate->heap()->undefined_value(); |
| (...skipping 3051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13548 } else { | 13548 } else { |
| 13549 // Handle last resort GC and make sure to allow future allocations | 13549 // Handle last resort GC and make sure to allow future allocations |
| 13550 // to grow the heap without causing GCs (if possible). | 13550 // to grow the heap without causing GCs (if possible). |
| 13551 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13551 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13552 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13552 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13553 } | 13553 } |
| 13554 } | 13554 } |
| 13555 | 13555 |
| 13556 | 13556 |
| 13557 } } // namespace v8::internal | 13557 } } // namespace v8::internal |
| OLD | NEW |