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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 int entry = dictionary->FindEntry(index); | 1066 int entry = dictionary->FindEntry(index); |
1067 ASSERT(entry != SeededNumberDictionary::kNotFound); | 1067 ASSERT(entry != SeededNumberDictionary::kNotFound); |
1068 PropertyDetails details = dictionary->DetailsAt(entry); | 1068 PropertyDetails details = dictionary->DetailsAt(entry); |
1069 switch (details.type()) { | 1069 switch (details.type()) { |
1070 case CALLBACKS: { | 1070 case CALLBACKS: { |
1071 // This is an accessor property with getter and/or setter. | 1071 // This is an accessor property with getter and/or setter. |
1072 AccessorPair* accessors = | 1072 AccessorPair* accessors = |
1073 AccessorPair::cast(dictionary->ValueAt(entry)); | 1073 AccessorPair::cast(dictionary->ValueAt(entry)); |
1074 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); | 1074 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); |
1075 if (CheckElementAccess(*obj, index, v8::ACCESS_GET)) { | 1075 if (CheckElementAccess(*obj, index, v8::ACCESS_GET)) { |
1076 elms->set(GETTER_INDEX, accessors->getter()); | 1076 elms->set(GETTER_INDEX, accessors->SafeGet(ACCESSOR_GETTER)); |
1077 } | 1077 } |
1078 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { | 1078 if (CheckElementAccess(*obj, index, v8::ACCESS_SET)) { |
1079 elms->set(SETTER_INDEX, accessors->setter()); | 1079 elms->set(SETTER_INDEX, accessors->SafeGet(ACCESSOR_SETTER)); |
1080 } | 1080 } |
1081 break; | 1081 break; |
1082 } | 1082 } |
1083 case NORMAL: { | 1083 case NORMAL: { |
1084 // This is a data property. | 1084 // This is a data property. |
1085 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); | 1085 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); |
1086 Handle<Object> value = Object::GetElement(obj, index); | 1086 Handle<Object> value = Object::GetElement(obj, index); |
1087 ASSERT(!value.is_null()); | 1087 ASSERT(!value.is_null()); |
1088 elms->set(VALUE_INDEX, *value); | 1088 elms->set(VALUE_INDEX, *value); |
1089 elms->set(WRITABLE_INDEX, heap->ToBoolean(!details.IsReadOnly())); | 1089 elms->set(WRITABLE_INDEX, heap->ToBoolean(!details.IsReadOnly())); |
(...skipping 26 matching lines...) Expand all Loading... | |
1116 | 1116 |
1117 bool is_js_accessor = (result.type() == CALLBACKS) && | 1117 bool is_js_accessor = (result.type() == CALLBACKS) && |
1118 (result.GetCallbackObject()->IsAccessorPair()); | 1118 (result.GetCallbackObject()->IsAccessorPair()); |
1119 | 1119 |
1120 if (is_js_accessor) { | 1120 if (is_js_accessor) { |
1121 // __defineGetter__/__defineSetter__ callback. | 1121 // __defineGetter__/__defineSetter__ callback. |
1122 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); | 1122 elms->set(IS_ACCESSOR_INDEX, heap->true_value()); |
1123 | 1123 |
1124 AccessorPair* accessors = AccessorPair::cast(result.GetCallbackObject()); | 1124 AccessorPair* accessors = AccessorPair::cast(result.GetCallbackObject()); |
1125 if (CheckAccess(*obj, *name, &result, v8::ACCESS_GET)) { | 1125 if (CheckAccess(*obj, *name, &result, v8::ACCESS_GET)) { |
1126 elms->set(GETTER_INDEX, accessors->getter()); | 1126 elms->set(GETTER_INDEX, accessors->SafeGet(ACCESSOR_GETTER)); |
1127 } | 1127 } |
1128 if (CheckAccess(*obj, *name, &result, v8::ACCESS_SET)) { | 1128 if (CheckAccess(*obj, *name, &result, v8::ACCESS_SET)) { |
1129 elms->set(SETTER_INDEX, accessors->setter()); | 1129 elms->set(SETTER_INDEX, accessors->SafeGet(ACCESSOR_SETTER)); |
1130 } | 1130 } |
1131 } else { | 1131 } else { |
1132 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); | 1132 elms->set(IS_ACCESSOR_INDEX, heap->false_value()); |
1133 elms->set(WRITABLE_INDEX, heap->ToBoolean(!result.IsReadOnly())); | 1133 elms->set(WRITABLE_INDEX, heap->ToBoolean(!result.IsReadOnly())); |
1134 | 1134 |
1135 PropertyAttributes attrs; | 1135 PropertyAttributes attrs; |
1136 Object* value; | 1136 Object* value; |
1137 // GetProperty will check access and report any violations. | 1137 // GetProperty will check access and report any violations. |
1138 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); | 1138 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); |
1139 if (!maybe_value->ToObject(&value)) return maybe_value; | 1139 if (!maybe_value->ToObject(&value)) return maybe_value; |
(...skipping 9347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10487 // If the callback object is a fixed array then it contains JavaScript | 10487 // If the callback object is a fixed array then it contains JavaScript |
10488 // getter and/or setter. | 10488 // getter and/or setter. |
10489 bool hasJavaScriptAccessors = result_type == CALLBACKS && | 10489 bool hasJavaScriptAccessors = result_type == CALLBACKS && |
10490 result_callback_obj->IsAccessorPair(); | 10490 result_callback_obj->IsAccessorPair(); |
10491 Handle<FixedArray> details = | 10491 Handle<FixedArray> details = |
10492 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); | 10492 isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
10493 details->set(0, *value); | 10493 details->set(0, *value); |
10494 details->set(1, property_details); | 10494 details->set(1, property_details); |
10495 if (hasJavaScriptAccessors) { | 10495 if (hasJavaScriptAccessors) { |
10496 details->set(2, isolate->heap()->ToBoolean(caught_exception)); | 10496 details->set(2, isolate->heap()->ToBoolean(caught_exception)); |
10497 details->set(3, AccessorPair::cast(*result_callback_obj)->getter()); | 10497 details->set(3, AccessorPair::cast(*result_callback_obj)->getter()); |
fschneider
2012/03/07 10:32:25
Is this call-site safe?
Sven Panne
2012/03/07 10:38:10
Good point, it's very probably not. New CL approac
| |
10498 details->set(4, AccessorPair::cast(*result_callback_obj)->setter()); | 10498 details->set(4, AccessorPair::cast(*result_callback_obj)->setter()); |
10499 } | 10499 } |
10500 | 10500 |
10501 return *isolate->factory()->NewJSArrayWithElements(details); | 10501 return *isolate->factory()->NewJSArrayWithElements(details); |
10502 } | 10502 } |
10503 if (i < length - 1) { | 10503 if (i < length - 1) { |
10504 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10504 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
10505 } | 10505 } |
10506 } | 10506 } |
10507 | 10507 |
(...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13623 // Handle last resort GC and make sure to allow future allocations | 13623 // Handle last resort GC and make sure to allow future allocations |
13624 // to grow the heap without causing GCs (if possible). | 13624 // to grow the heap without causing GCs (if possible). |
13625 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13625 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13626 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13626 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13627 "Runtime::PerformGC"); | 13627 "Runtime::PerformGC"); |
13628 } | 13628 } |
13629 } | 13629 } |
13630 | 13630 |
13631 | 13631 |
13632 } } // namespace v8::internal | 13632 } } // namespace v8::internal |
OLD | NEW |