| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (structure->IsForeign()) { | 173 if (structure->IsForeign()) { |
| 174 AccessorDescriptor* callback = | 174 AccessorDescriptor* callback = |
| 175 reinterpret_cast<AccessorDescriptor*>( | 175 reinterpret_cast<AccessorDescriptor*>( |
| 176 Foreign::cast(structure)->foreign_address()); | 176 Foreign::cast(structure)->foreign_address()); |
| 177 MaybeObject* value = (callback->getter)(receiver, callback->data); | 177 MaybeObject* value = (callback->getter)(receiver, callback->data); |
| 178 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 178 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 179 return value; | 179 return value; |
| 180 } | 180 } |
| 181 | 181 |
| 182 // api style callbacks. | 182 // api style callbacks. |
| 183 if (structure->IsAccessorInfo()) { | 183 if (structure->IsExecutableAccessorInfo()) { |
| 184 AccessorInfo* data = AccessorInfo::cast(structure); | 184 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); |
| 185 if (!data->IsCompatibleReceiver(receiver)) { | 185 if (!data->IsCompatibleReceiver(receiver)) { |
| 186 Handle<Object> name_handle(name); | 186 Handle<Object> name_handle(name); |
| 187 Handle<Object> receiver_handle(receiver); | 187 Handle<Object> receiver_handle(receiver); |
| 188 Handle<Object> args[2] = { name_handle, receiver_handle }; | 188 Handle<Object> args[2] = { name_handle, receiver_handle }; |
| 189 Handle<Object> error = | 189 Handle<Object> error = |
| 190 isolate->factory()->NewTypeError("incompatible_method_receiver", | 190 isolate->factory()->NewTypeError("incompatible_method_receiver", |
| 191 HandleVector(args, | 191 HandleVector(args, |
| 192 ARRAY_SIZE(args))); | 192 ARRAY_SIZE(args))); |
| 193 return isolate->Throw(*error); | 193 return isolate->Throw(*error); |
| 194 } | 194 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 220 if (structure->IsAccessorPair()) { | 220 if (structure->IsAccessorPair()) { |
| 221 Object* getter = AccessorPair::cast(structure)->getter(); | 221 Object* getter = AccessorPair::cast(structure)->getter(); |
| 222 if (getter->IsSpecFunction()) { | 222 if (getter->IsSpecFunction()) { |
| 223 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 223 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 224 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); | 224 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); |
| 225 } | 225 } |
| 226 // Getter is not a function. | 226 // Getter is not a function. |
| 227 return isolate->heap()->undefined_value(); | 227 return isolate->heap()->undefined_value(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // TODO(dcarney): Handle correctly. |
| 231 if (structure->IsDeclaredAccessorInfo()) { |
| 232 return isolate->heap()->undefined_value(); |
| 233 } |
| 234 |
| 230 UNREACHABLE(); | 235 UNREACHABLE(); |
| 231 return NULL; | 236 return NULL; |
| 232 } | 237 } |
| 233 | 238 |
| 234 | 239 |
| 235 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw, | 240 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw, |
| 236 String* name_raw) { | 241 String* name_raw) { |
| 237 Isolate* isolate = GetIsolate(); | 242 Isolate* isolate = GetIsolate(); |
| 238 HandleScope scope(isolate); | 243 HandleScope scope(isolate); |
| 239 Handle<Object> receiver(receiver_raw); | 244 Handle<Object> receiver(receiver_raw); |
| (...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 if (structure->IsForeign()) { | 2001 if (structure->IsForeign()) { |
| 1997 AccessorDescriptor* callback = | 2002 AccessorDescriptor* callback = |
| 1998 reinterpret_cast<AccessorDescriptor*>( | 2003 reinterpret_cast<AccessorDescriptor*>( |
| 1999 Foreign::cast(structure)->foreign_address()); | 2004 Foreign::cast(structure)->foreign_address()); |
| 2000 MaybeObject* obj = (callback->setter)(this, value, callback->data); | 2005 MaybeObject* obj = (callback->setter)(this, value, callback->data); |
| 2001 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 2006 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 2002 if (obj->IsFailure()) return obj; | 2007 if (obj->IsFailure()) return obj; |
| 2003 return *value_handle; | 2008 return *value_handle; |
| 2004 } | 2009 } |
| 2005 | 2010 |
| 2006 if (structure->IsAccessorInfo()) { | 2011 if (structure->IsExecutableAccessorInfo()) { |
| 2007 // api style callbacks | 2012 // api style callbacks |
| 2008 AccessorInfo* data = AccessorInfo::cast(structure); | 2013 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); |
| 2009 if (!data->IsCompatibleReceiver(this)) { | 2014 if (!data->IsCompatibleReceiver(this)) { |
| 2010 Handle<Object> name_handle(name); | 2015 Handle<Object> name_handle(name); |
| 2011 Handle<Object> receiver_handle(this); | 2016 Handle<Object> receiver_handle(this); |
| 2012 Handle<Object> args[2] = { name_handle, receiver_handle }; | 2017 Handle<Object> args[2] = { name_handle, receiver_handle }; |
| 2013 Handle<Object> error = | 2018 Handle<Object> error = |
| 2014 isolate->factory()->NewTypeError("incompatible_method_receiver", | 2019 isolate->factory()->NewTypeError("incompatible_method_receiver", |
| 2015 HandleVector(args, | 2020 HandleVector(args, |
| 2016 ARRAY_SIZE(args))); | 2021 ARRAY_SIZE(args))); |
| 2017 return isolate->Throw(*error); | 2022 return isolate->Throw(*error); |
| 2018 } | 2023 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2045 } | 2050 } |
| 2046 Handle<String> key(name); | 2051 Handle<String> key(name); |
| 2047 Handle<Object> holder_handle(holder, isolate); | 2052 Handle<Object> holder_handle(holder, isolate); |
| 2048 Handle<Object> args[2] = { key, holder_handle }; | 2053 Handle<Object> args[2] = { key, holder_handle }; |
| 2049 return isolate->Throw( | 2054 return isolate->Throw( |
| 2050 *isolate->factory()->NewTypeError("no_setter_in_callback", | 2055 *isolate->factory()->NewTypeError("no_setter_in_callback", |
| 2051 HandleVector(args, 2))); | 2056 HandleVector(args, 2))); |
| 2052 } | 2057 } |
| 2053 } | 2058 } |
| 2054 | 2059 |
| 2060 // TODO(dcarney): Handle correctly. |
| 2061 if (structure->IsDeclaredAccessorInfo()) { |
| 2062 return value; |
| 2063 } |
| 2064 |
| 2055 UNREACHABLE(); | 2065 UNREACHABLE(); |
| 2056 return NULL; | 2066 return NULL; |
| 2057 } | 2067 } |
| 2058 | 2068 |
| 2059 | 2069 |
| 2060 MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter, | 2070 MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter, |
| 2061 Object* value) { | 2071 Object* value) { |
| 2062 Isolate* isolate = GetIsolate(); | 2072 Isolate* isolate = GetIsolate(); |
| 2063 Handle<Object> value_handle(value, isolate); | 2073 Handle<Object> value_handle(value, isolate); |
| 2064 Handle<JSReceiver> fun(setter, isolate); | 2074 Handle<JSReceiver> fun(setter, isolate); |
| (...skipping 7661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9726 | 9736 |
| 9727 | 9737 |
| 9728 MaybeObject* JSObject::GetElementWithCallback(Object* receiver, | 9738 MaybeObject* JSObject::GetElementWithCallback(Object* receiver, |
| 9729 Object* structure, | 9739 Object* structure, |
| 9730 uint32_t index, | 9740 uint32_t index, |
| 9731 Object* holder) { | 9741 Object* holder) { |
| 9732 Isolate* isolate = GetIsolate(); | 9742 Isolate* isolate = GetIsolate(); |
| 9733 ASSERT(!structure->IsForeign()); | 9743 ASSERT(!structure->IsForeign()); |
| 9734 | 9744 |
| 9735 // api style callbacks. | 9745 // api style callbacks. |
| 9736 if (structure->IsAccessorInfo()) { | 9746 if (structure->IsExecutableAccessorInfo()) { |
| 9737 Handle<AccessorInfo> data(AccessorInfo::cast(structure)); | 9747 Handle<ExecutableAccessorInfo> data( |
| 9748 ExecutableAccessorInfo::cast(structure)); |
| 9738 Object* fun_obj = data->getter(); | 9749 Object* fun_obj = data->getter(); |
| 9739 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); | 9750 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
| 9740 if (call_fun == NULL) return isolate->heap()->undefined_value(); | 9751 if (call_fun == NULL) return isolate->heap()->undefined_value(); |
| 9741 HandleScope scope(isolate); | 9752 HandleScope scope(isolate); |
| 9742 Handle<JSObject> self(JSObject::cast(receiver)); | 9753 Handle<JSObject> self(JSObject::cast(receiver)); |
| 9743 Handle<JSObject> holder_handle(JSObject::cast(holder)); | 9754 Handle<JSObject> holder_handle(JSObject::cast(holder)); |
| 9744 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 9755 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
| 9745 Handle<String> key = isolate->factory()->NumberToString(number); | 9756 Handle<String> key = isolate->factory()->NumberToString(number); |
| 9746 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); | 9757 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); |
| 9747 CustomArguments args(isolate, data->data(), *self, *holder_handle); | 9758 CustomArguments args(isolate, data->data(), *self, *holder_handle); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9763 if (structure->IsAccessorPair()) { | 9774 if (structure->IsAccessorPair()) { |
| 9764 Object* getter = AccessorPair::cast(structure)->getter(); | 9775 Object* getter = AccessorPair::cast(structure)->getter(); |
| 9765 if (getter->IsSpecFunction()) { | 9776 if (getter->IsSpecFunction()) { |
| 9766 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 9777 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 9767 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); | 9778 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); |
| 9768 } | 9779 } |
| 9769 // Getter is not a function. | 9780 // Getter is not a function. |
| 9770 return isolate->heap()->undefined_value(); | 9781 return isolate->heap()->undefined_value(); |
| 9771 } | 9782 } |
| 9772 | 9783 |
| 9784 if (structure->IsDeclaredAccessorInfo()) { |
| 9785 // TODO(dcarney): Handle correctly. |
| 9786 return isolate->heap()->undefined_value(); |
| 9787 } |
| 9788 |
| 9773 UNREACHABLE(); | 9789 UNREACHABLE(); |
| 9774 return NULL; | 9790 return NULL; |
| 9775 } | 9791 } |
| 9776 | 9792 |
| 9777 | 9793 |
| 9778 MaybeObject* JSObject::SetElementWithCallback(Object* structure, | 9794 MaybeObject* JSObject::SetElementWithCallback(Object* structure, |
| 9779 uint32_t index, | 9795 uint32_t index, |
| 9780 Object* value, | 9796 Object* value, |
| 9781 JSObject* holder, | 9797 JSObject* holder, |
| 9782 StrictModeFlag strict_mode) { | 9798 StrictModeFlag strict_mode) { |
| 9783 Isolate* isolate = GetIsolate(); | 9799 Isolate* isolate = GetIsolate(); |
| 9784 HandleScope scope(isolate); | 9800 HandleScope scope(isolate); |
| 9785 | 9801 |
| 9786 // We should never get here to initialize a const with the hole | 9802 // We should never get here to initialize a const with the hole |
| 9787 // value since a const declaration would conflict with the setter. | 9803 // value since a const declaration would conflict with the setter. |
| 9788 ASSERT(!value->IsTheHole()); | 9804 ASSERT(!value->IsTheHole()); |
| 9789 Handle<Object> value_handle(value, isolate); | 9805 Handle<Object> value_handle(value, isolate); |
| 9790 | 9806 |
| 9791 // To accommodate both the old and the new api we switch on the | 9807 // To accommodate both the old and the new api we switch on the |
| 9792 // data structure used to store the callbacks. Eventually foreign | 9808 // data structure used to store the callbacks. Eventually foreign |
| 9793 // callbacks should be phased out. | 9809 // callbacks should be phased out. |
| 9794 ASSERT(!structure->IsForeign()); | 9810 ASSERT(!structure->IsForeign()); |
| 9795 | 9811 |
| 9796 if (structure->IsAccessorInfo()) { | 9812 if (structure->IsExecutableAccessorInfo()) { |
| 9797 // api style callbacks | 9813 // api style callbacks |
| 9798 Handle<JSObject> self(this); | 9814 Handle<JSObject> self(this); |
| 9799 Handle<JSObject> holder_handle(JSObject::cast(holder)); | 9815 Handle<JSObject> holder_handle(JSObject::cast(holder)); |
| 9800 Handle<AccessorInfo> data(AccessorInfo::cast(structure)); | 9816 Handle<ExecutableAccessorInfo> data( |
| 9817 ExecutableAccessorInfo::cast(structure)); |
| 9801 Object* call_obj = data->setter(); | 9818 Object* call_obj = data->setter(); |
| 9802 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); | 9819 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
| 9803 if (call_fun == NULL) return value; | 9820 if (call_fun == NULL) return value; |
| 9804 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 9821 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
| 9805 Handle<String> key(isolate->factory()->NumberToString(number)); | 9822 Handle<String> key(isolate->factory()->NumberToString(number)); |
| 9806 LOG(isolate, ApiNamedPropertyAccess("store", *self, *key)); | 9823 LOG(isolate, ApiNamedPropertyAccess("store", *self, *key)); |
| 9807 CustomArguments args(isolate, data->data(), *self, *holder_handle); | 9824 CustomArguments args(isolate, data->data(), *self, *holder_handle); |
| 9808 v8::AccessorInfo info(args.end()); | 9825 v8::AccessorInfo info(args.end()); |
| 9809 { | 9826 { |
| 9810 // Leaving JavaScript. | 9827 // Leaving JavaScript. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9828 } | 9845 } |
| 9829 Handle<Object> holder_handle(holder, isolate); | 9846 Handle<Object> holder_handle(holder, isolate); |
| 9830 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 9847 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); |
| 9831 Handle<Object> args[2] = { key, holder_handle }; | 9848 Handle<Object> args[2] = { key, holder_handle }; |
| 9832 return isolate->Throw( | 9849 return isolate->Throw( |
| 9833 *isolate->factory()->NewTypeError("no_setter_in_callback", | 9850 *isolate->factory()->NewTypeError("no_setter_in_callback", |
| 9834 HandleVector(args, 2))); | 9851 HandleVector(args, 2))); |
| 9835 } | 9852 } |
| 9836 } | 9853 } |
| 9837 | 9854 |
| 9855 // TODO(dcarney): Handle correctly. |
| 9856 if (structure->IsDeclaredAccessorInfo()) return value; |
| 9857 |
| 9838 UNREACHABLE(); | 9858 UNREACHABLE(); |
| 9839 return NULL; | 9859 return NULL; |
| 9840 } | 9860 } |
| 9841 | 9861 |
| 9842 | 9862 |
| 9843 bool JSObject::HasFastArgumentsElements() { | 9863 bool JSObject::HasFastArgumentsElements() { |
| 9844 Heap* heap = GetHeap(); | 9864 Heap* heap = GetHeap(); |
| 9845 if (!elements()->IsFixedArray()) return false; | 9865 if (!elements()->IsFixedArray()) return false; |
| 9846 FixedArray* elements = FixedArray::cast(this->elements()); | 9866 FixedArray* elements = FixedArray::cast(this->elements()); |
| 9847 if (elements->map() != heap->non_strict_arguments_elements_map()) { | 9867 if (elements->map() != heap->non_strict_arguments_elements_map()) { |
| (...skipping 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13892 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13912 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13893 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13913 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13894 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13914 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13895 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13915 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13896 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13916 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13897 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13917 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13898 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13918 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13899 } | 13919 } |
| 13900 | 13920 |
| 13901 } } // namespace v8::internal | 13921 } } // namespace v8::internal |
| OLD | NEW |