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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
974 Object* prototype = V->GetPrototype(); | 974 Object* prototype = V->GetPrototype(); |
975 if (prototype->IsNull()) return isolate->heap()->false_value(); | 975 if (prototype->IsNull()) return isolate->heap()->false_value(); |
976 if (O == prototype) return isolate->heap()->true_value(); | 976 if (O == prototype) return isolate->heap()->true_value(); |
977 V = prototype; | 977 V = prototype; |
978 } | 978 } |
979 } | 979 } |
980 | 980 |
981 | 981 |
982 static bool CheckAccessException(Object* callback, | 982 static bool CheckAccessException(Object* callback, |
983 v8::AccessType access_type) { | 983 v8::AccessType access_type) { |
984 if (callback->IsAccessorInfo()) { | 984 AccessorInfo* info = 0; |
Sven Panne
2013/02/07 10:01:03
Again, this should stay as it is.
| |
985 AccessorInfo* info = AccessorInfo::cast(callback); | 985 if (callback->IsExecutableAccessorInfo()) { |
986 return | 986 info = ExecutableAccessorInfo::cast(callback); |
987 (access_type == v8::ACCESS_HAS && | 987 } else if (callback->IsDeclaredAccessorInfo()) { |
988 (info->all_can_read() || info->all_can_write())) || | 988 info = DeclaredAccessorInfo::cast(callback); |
989 (access_type == v8::ACCESS_GET && info->all_can_read()) || | 989 } else { |
990 (access_type == v8::ACCESS_SET && info->all_can_write()); | 990 return false; |
991 } | 991 } |
992 return false; | 992 return |
993 (access_type == v8::ACCESS_HAS && | |
994 (info->all_can_read() || info->all_can_write())) || | |
995 (access_type == v8::ACCESS_GET && info->all_can_read()) || | |
996 (access_type == v8::ACCESS_SET && info->all_can_write()); | |
993 } | 997 } |
994 | 998 |
995 | 999 |
996 template<class Key> | 1000 template<class Key> |
997 static bool CheckGenericAccess( | 1001 static bool CheckGenericAccess( |
998 JSObject* receiver, | 1002 JSObject* receiver, |
999 JSObject* holder, | 1003 JSObject* holder, |
1000 Key key, | 1004 Key key, |
1001 v8::AccessType access_type, | 1005 v8::AccessType access_type, |
1002 bool (Isolate::*mayAccess)(JSObject*, Key, v8::AccessType)) { | 1006 bool (Isolate::*mayAccess)(JSObject*, Key, v8::AccessType)) { |
(...skipping 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4104 | 4108 |
4105 LookupResult result(isolate); | 4109 LookupResult result(isolate); |
4106 js_object->LocalLookupRealNamedProperty(*name, &result); | 4110 js_object->LocalLookupRealNamedProperty(*name, &result); |
4107 | 4111 |
4108 // Special case for callback properties. | 4112 // Special case for callback properties. |
4109 if (result.IsPropertyCallbacks()) { | 4113 if (result.IsPropertyCallbacks()) { |
4110 Object* callback = result.GetCallbackObject(); | 4114 Object* callback = result.GetCallbackObject(); |
4111 // To be compatible with Safari we do not change the value on API objects | 4115 // To be compatible with Safari we do not change the value on API objects |
4112 // in Object.defineProperty(). Firefox disagrees here, and actually changes | 4116 // in Object.defineProperty(). Firefox disagrees here, and actually changes |
4113 // the value. | 4117 // the value. |
4114 if (callback->IsAccessorInfo()) { | 4118 if (callback->IsExecutableAccessorInfo() || |
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
4119 callback->IsDeclaredAccessorInfo()) { | |
4115 return isolate->heap()->undefined_value(); | 4120 return isolate->heap()->undefined_value(); |
4116 } | 4121 } |
4117 // Avoid redefining foreign callback as data property, just use the stored | 4122 // Avoid redefining foreign callback as data property, just use the stored |
4118 // setter to update the value instead. | 4123 // setter to update the value instead. |
4119 // TODO(mstarzinger): So far this only works if property attributes don't | 4124 // TODO(mstarzinger): So far this only works if property attributes don't |
4120 // change, this should be fixed once we cleanup the underlying code. | 4125 // change, this should be fixed once we cleanup the underlying code. |
4121 if (callback->IsForeign() && result.GetAttributes() == attr) { | 4126 if (callback->IsForeign() && result.GetAttributes() == attr) { |
4122 return js_object->SetPropertyWithCallback(callback, | 4127 return js_object->SetPropertyWithCallback(callback, |
4123 *name, | 4128 *name, |
4124 *obj_value, | 4129 *obj_value, |
(...skipping 6016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10141 JSObject::cast(result->holder())->FastPropertyAt( | 10146 JSObject::cast(result->holder())->FastPropertyAt( |
10142 result->GetFieldIndex().field_index()); | 10147 result->GetFieldIndex().field_index()); |
10143 if (value->IsTheHole()) { | 10148 if (value->IsTheHole()) { |
10144 return heap->undefined_value(); | 10149 return heap->undefined_value(); |
10145 } | 10150 } |
10146 return value; | 10151 return value; |
10147 case CONSTANT_FUNCTION: | 10152 case CONSTANT_FUNCTION: |
10148 return result->GetConstantFunction(); | 10153 return result->GetConstantFunction(); |
10149 case CALLBACKS: { | 10154 case CALLBACKS: { |
10150 Object* structure = result->GetCallbackObject(); | 10155 Object* structure = result->GetCallbackObject(); |
10151 if (structure->IsForeign() || structure->IsAccessorInfo()) { | 10156 if (structure->IsForeign() || |
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
10157 structure->IsExecutableAccessorInfo() || | |
10158 structure->IsDeclaredAccessorInfo()) { | |
10152 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( | 10159 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( |
10153 receiver, structure, name); | 10160 receiver, structure, name); |
10154 if (!maybe_value->ToObject(&value)) { | 10161 if (!maybe_value->ToObject(&value)) { |
10155 if (maybe_value->IsRetryAfterGC()) return maybe_value; | 10162 if (maybe_value->IsRetryAfterGC()) return maybe_value; |
10156 ASSERT(maybe_value->IsException()); | 10163 ASSERT(maybe_value->IsException()); |
10157 maybe_value = heap->isolate()->pending_exception(); | 10164 maybe_value = heap->isolate()->pending_exception(); |
10158 heap->isolate()->clear_pending_exception(); | 10165 heap->isolate()->clear_pending_exception(); |
10159 if (caught_exception != NULL) { | 10166 if (caught_exception != NULL) { |
10160 *caught_exception = true; | 10167 *caught_exception = true; |
10161 } | 10168 } |
(...skipping 3365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13527 // Handle last resort GC and make sure to allow future allocations | 13534 // Handle last resort GC and make sure to allow future allocations |
13528 // to grow the heap without causing GCs (if possible). | 13535 // to grow the heap without causing GCs (if possible). |
13529 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13536 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13530 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13537 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13531 "Runtime::PerformGC"); | 13538 "Runtime::PerformGC"); |
13532 } | 13539 } |
13533 } | 13540 } |
13534 | 13541 |
13535 | 13542 |
13536 } } // namespace v8::internal | 13543 } } // namespace v8::internal |
OLD | NEW |