Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( | 329 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( |
| 325 Object* receiver, | 330 Object* receiver, |
| 326 LookupResult* result, | 331 LookupResult* result, |
| 327 String* name, | 332 String* name, |
| 328 PropertyAttributes* attributes) { | 333 PropertyAttributes* attributes) { |
| 329 if (result->IsProperty()) { | 334 if (result->IsProperty()) { |
| 330 switch (result->type()) { | 335 switch (result->type()) { |
| 331 case CALLBACKS: { | 336 case CALLBACKS: { |
| 332 // Only allow API accessors. | 337 // Only allow API accessors. |
| 333 Object* obj = result->GetCallbackObject(); | 338 Object* obj = result->GetCallbackObject(); |
| 334 if (obj->IsAccessorInfo()) { | 339 if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
I think the old code should stay as it is and inst
| |
| 335 AccessorInfo* info = AccessorInfo::cast(obj); | 340 if (!ExecutableAccessorInfo::cast(obj)->all_can_read()) break; |
| 336 if (info->all_can_read()) { | 341 } else if (obj->IsDeclaredAccessorInfo()) { |
| 337 *attributes = result->GetAttributes(); | 342 if (!DeclaredAccessorInfo::cast(obj)->all_can_read()) break; |
| 338 return result->holder()->GetPropertyWithCallback( | 343 } else { break; } |
| 339 receiver, result->GetCallbackObject(), name); | 344 *attributes = result->GetAttributes(); |
| 340 } | 345 return result->holder()->GetPropertyWithCallback( |
| 341 } | 346 receiver, result->GetCallbackObject(), name); |
| 342 break; | |
| 343 } | 347 } |
| 344 case NORMAL: | 348 case NORMAL: |
| 345 case FIELD: | 349 case FIELD: |
| 346 case CONSTANT_FUNCTION: { | 350 case CONSTANT_FUNCTION: { |
| 347 // Search ALL_CAN_READ accessors in prototype chain. | 351 // Search ALL_CAN_READ accessors in prototype chain. |
| 348 LookupResult r(GetIsolate()); | 352 LookupResult r(GetIsolate()); |
| 349 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 353 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
| 350 if (r.IsProperty()) { | 354 if (r.IsProperty()) { |
| 351 return GetPropertyWithFailedAccessCheck(receiver, | 355 return GetPropertyWithFailedAccessCheck(receiver, |
| 352 &r, | 356 &r, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( | 388 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 385 Object* receiver, | 389 Object* receiver, |
| 386 LookupResult* result, | 390 LookupResult* result, |
| 387 String* name, | 391 String* name, |
| 388 bool continue_search) { | 392 bool continue_search) { |
| 389 if (result->IsProperty()) { | 393 if (result->IsProperty()) { |
| 390 switch (result->type()) { | 394 switch (result->type()) { |
| 391 case CALLBACKS: { | 395 case CALLBACKS: { |
| 392 // Only allow API accessors. | 396 // Only allow API accessors. |
| 393 Object* obj = result->GetCallbackObject(); | 397 Object* obj = result->GetCallbackObject(); |
| 394 if (obj->IsAccessorInfo()) { | 398 if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
| 395 AccessorInfo* info = AccessorInfo::cast(obj); | 399 if (!ExecutableAccessorInfo::cast(obj)->all_can_read()) break; |
| 396 if (info->all_can_read()) { | 400 } else if (obj->IsDeclaredAccessorInfo()) { |
| 397 return result->GetAttributes(); | 401 if (!DeclaredAccessorInfo::cast(obj)->all_can_read()) break; |
| 398 } | 402 } else { break; } |
| 399 } | 403 return result->GetAttributes(); |
| 400 break; | |
| 401 } | 404 } |
| 402 | 405 |
| 403 case NORMAL: | 406 case NORMAL: |
| 404 case FIELD: | 407 case FIELD: |
| 405 case CONSTANT_FUNCTION: { | 408 case CONSTANT_FUNCTION: { |
| 406 if (!continue_search) break; | 409 if (!continue_search) break; |
| 407 // Search ALL_CAN_READ accessors in prototype chain. | 410 // Search ALL_CAN_READ accessors in prototype chain. |
| 408 LookupResult r(GetIsolate()); | 411 LookupResult r(GetIsolate()); |
| 409 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 412 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); |
| 410 if (r.IsProperty()) { | 413 if (r.IsProperty()) { |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1996 if (structure->IsForeign()) { | 1999 if (structure->IsForeign()) { |
| 1997 AccessorDescriptor* callback = | 2000 AccessorDescriptor* callback = |
| 1998 reinterpret_cast<AccessorDescriptor*>( | 2001 reinterpret_cast<AccessorDescriptor*>( |
| 1999 Foreign::cast(structure)->foreign_address()); | 2002 Foreign::cast(structure)->foreign_address()); |
| 2000 MaybeObject* obj = (callback->setter)(this, value, callback->data); | 2003 MaybeObject* obj = (callback->setter)(this, value, callback->data); |
| 2001 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 2004 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 2002 if (obj->IsFailure()) return obj; | 2005 if (obj->IsFailure()) return obj; |
| 2003 return *value_handle; | 2006 return *value_handle; |
| 2004 } | 2007 } |
| 2005 | 2008 |
| 2006 if (structure->IsAccessorInfo()) { | 2009 if (structure->IsExecutableAccessorInfo()) { |
| 2007 // api style callbacks | 2010 // api style callbacks |
| 2008 AccessorInfo* data = AccessorInfo::cast(structure); | 2011 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); |
| 2009 if (!data->IsCompatibleReceiver(this)) { | 2012 if (!data->IsCompatibleReceiver(this)) { |
| 2010 Handle<Object> name_handle(name); | 2013 Handle<Object> name_handle(name); |
| 2011 Handle<Object> receiver_handle(this); | 2014 Handle<Object> receiver_handle(this); |
| 2012 Handle<Object> args[2] = { name_handle, receiver_handle }; | 2015 Handle<Object> args[2] = { name_handle, receiver_handle }; |
| 2013 Handle<Object> error = | 2016 Handle<Object> error = |
| 2014 isolate->factory()->NewTypeError("incompatible_method_receiver", | 2017 isolate->factory()->NewTypeError("incompatible_method_receiver", |
| 2015 HandleVector(args, | 2018 HandleVector(args, |
| 2016 ARRAY_SIZE(args))); | 2019 ARRAY_SIZE(args))); |
| 2017 return isolate->Throw(*error); | 2020 return isolate->Throw(*error); |
| 2018 } | 2021 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 2045 } | 2048 } |
| 2046 Handle<String> key(name); | 2049 Handle<String> key(name); |
| 2047 Handle<Object> holder_handle(holder, isolate); | 2050 Handle<Object> holder_handle(holder, isolate); |
| 2048 Handle<Object> args[2] = { key, holder_handle }; | 2051 Handle<Object> args[2] = { key, holder_handle }; |
| 2049 return isolate->Throw( | 2052 return isolate->Throw( |
| 2050 *isolate->factory()->NewTypeError("no_setter_in_callback", | 2053 *isolate->factory()->NewTypeError("no_setter_in_callback", |
| 2051 HandleVector(args, 2))); | 2054 HandleVector(args, 2))); |
| 2052 } | 2055 } |
| 2053 } | 2056 } |
| 2054 | 2057 |
| 2058 // TODO(dcarney): Handle correctly. | |
| 2059 if (structure->IsDeclaredAccessorInfo()) { | |
| 2060 return value; | |
| 2061 } | |
| 2062 | |
| 2055 UNREACHABLE(); | 2063 UNREACHABLE(); |
| 2056 return NULL; | 2064 return NULL; |
| 2057 } | 2065 } |
| 2058 | 2066 |
| 2059 | 2067 |
| 2060 MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter, | 2068 MaybeObject* JSReceiver::SetPropertyWithDefinedSetter(JSReceiver* setter, |
| 2061 Object* value) { | 2069 Object* value) { |
| 2062 Isolate* isolate = GetIsolate(); | 2070 Isolate* isolate = GetIsolate(); |
| 2063 Handle<Object> value_handle(value, isolate); | 2071 Handle<Object> value_handle(value, isolate); |
| 2064 Handle<JSReceiver> fun(setter, isolate); | 2072 Handle<JSReceiver> fun(setter, isolate); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2252 Handle<DescriptorArray> array(map->instance_descriptors()); | 2260 Handle<DescriptorArray> array(map->instance_descriptors()); |
| 2253 NeanderArray callbacks(descriptors); | 2261 NeanderArray callbacks(descriptors); |
| 2254 int nof_callbacks = callbacks.length(); | 2262 int nof_callbacks = callbacks.length(); |
| 2255 | 2263 |
| 2256 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks); | 2264 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks); |
| 2257 | 2265 |
| 2258 // Ensure the keys are symbols before writing them into the instance | 2266 // Ensure the keys are symbols before writing them into the instance |
| 2259 // descriptor. Since it may cause a GC, it has to be done before we | 2267 // descriptor. Since it may cause a GC, it has to be done before we |
| 2260 // temporarily put the heap in an invalid state while appending descriptors. | 2268 // temporarily put the heap in an invalid state while appending descriptors. |
| 2261 for (int i = 0; i < nof_callbacks; ++i) { | 2269 for (int i = 0; i < nof_callbacks; ++i) { |
| 2262 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks.get(i))); | 2270 Object* callback = callbacks.get(i); |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
| 2271 AccessorInfo* ptr; | |
| 2272 if (callback->IsExecutableAccessorInfo()) { | |
| 2273 ptr = ExecutableAccessorInfo::cast(callback); | |
| 2274 } else { | |
| 2275 ptr = DeclaredAccessorInfo::cast(callback); | |
| 2276 } | |
| 2277 Handle<AccessorInfo> entry(ptr); | |
| 2263 Handle<String> key = | 2278 Handle<String> key = |
| 2264 isolate->factory()->SymbolFromString( | 2279 isolate->factory()->SymbolFromString( |
| 2265 Handle<String>(String::cast(entry->name()))); | 2280 Handle<String>(String::cast(entry->name()))); |
| 2266 entry->set_name(*key); | 2281 entry->set_name(*key); |
| 2267 } | 2282 } |
| 2268 | 2283 |
| 2269 int nof = map->NumberOfOwnDescriptors(); | 2284 int nof = map->NumberOfOwnDescriptors(); |
| 2270 | 2285 |
| 2271 // Fill in new callback descriptors. Process the callbacks from | 2286 // Fill in new callback descriptors. Process the callbacks from |
| 2272 // back to front so that the last callback with a given name takes | 2287 // back to front so that the last callback with a given name takes |
| 2273 // precedence over previously added callbacks with that name. | 2288 // precedence over previously added callbacks with that name. |
| 2274 for (int i = nof_callbacks - 1; i >= 0; i--) { | 2289 for (int i = nof_callbacks - 1; i >= 0; i--) { |
| 2275 AccessorInfo* entry = AccessorInfo::cast(callbacks.get(i)); | 2290 Object* callback = callbacks.get(i); |
| 2291 AccessorInfo* entry; | |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
| 2292 if (callback->IsExecutableAccessorInfo()) { | |
| 2293 entry = ExecutableAccessorInfo::cast(callback); | |
| 2294 } else { | |
| 2295 entry = DeclaredAccessorInfo::cast(callback); | |
| 2296 } | |
| 2276 String* key = String::cast(entry->name()); | 2297 String* key = String::cast(entry->name()); |
| 2277 // Check if a descriptor with this name already exists before writing. | 2298 // Check if a descriptor with this name already exists before writing. |
| 2278 if (array->Search(key, nof) == DescriptorArray::kNotFound) { | 2299 if (array->Search(key, nof) == DescriptorArray::kNotFound) { |
| 2279 CallbacksDescriptor desc(key, entry, entry->property_attributes()); | 2300 CallbacksDescriptor desc(key, entry, entry->property_attributes()); |
| 2280 array->Append(&desc); | 2301 array->Append(&desc); |
| 2281 nof += 1; | 2302 nof += 1; |
| 2282 } | 2303 } |
| 2283 } | 2304 } |
| 2284 | 2305 |
| 2285 map->SetNumberOfOwnDescriptors(nof); | 2306 map->SetNumberOfOwnDescriptors(nof); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2515 StrictModeFlag strict_mode) { | 2536 StrictModeFlag strict_mode) { |
| 2516 if (check_prototype && !result->IsProperty()) { | 2537 if (check_prototype && !result->IsProperty()) { |
| 2517 LookupRealNamedPropertyInPrototypes(name, result); | 2538 LookupRealNamedPropertyInPrototypes(name, result); |
| 2518 } | 2539 } |
| 2519 | 2540 |
| 2520 if (result->IsProperty()) { | 2541 if (result->IsProperty()) { |
| 2521 if (!result->IsReadOnly()) { | 2542 if (!result->IsReadOnly()) { |
| 2522 switch (result->type()) { | 2543 switch (result->type()) { |
| 2523 case CALLBACKS: { | 2544 case CALLBACKS: { |
| 2524 Object* obj = result->GetCallbackObject(); | 2545 Object* obj = result->GetCallbackObject(); |
| 2525 if (obj->IsAccessorInfo()) { | 2546 if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
| 2526 AccessorInfo* info = AccessorInfo::cast(obj); | 2547 if (!ExecutableAccessorInfo::cast(obj)->all_can_write()) break; |
| 2527 if (info->all_can_write()) { | 2548 } else if (obj->IsDeclaredAccessorInfo()) { |
| 2528 return SetPropertyWithCallback(result->GetCallbackObject(), | 2549 if (!DeclaredAccessorInfo::cast(obj)->all_can_write()) break; |
| 2529 name, | 2550 } else { break; } |
| 2530 value, | 2551 return SetPropertyWithCallback(result->GetCallbackObject(), |
| 2531 result->holder(), | 2552 name, |
| 2532 strict_mode); | 2553 value, |
| 2533 } | 2554 result->holder(), |
| 2534 } | 2555 strict_mode); |
| 2535 break; | |
| 2536 } | 2556 } |
| 2537 case INTERCEPTOR: { | 2557 case INTERCEPTOR: { |
| 2538 // Try lookup real named properties. Note that only property can be | 2558 // Try lookup real named properties. Note that only property can be |
| 2539 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain. | 2559 // set is callbacks marked as ALL_CAN_WRITE on the prototype chain. |
| 2540 LookupResult r(GetIsolate()); | 2560 LookupResult r(GetIsolate()); |
| 2541 LookupRealNamedProperty(name, &r); | 2561 LookupRealNamedProperty(name, &r); |
| 2542 if (r.IsProperty()) { | 2562 if (r.IsProperty()) { |
| 2543 return SetPropertyWithFailedAccessCheck(&r, | 2563 return SetPropertyWithFailedAccessCheck(&r, |
| 2544 name, | 2564 name, |
| 2545 value, | 2565 value, |
| (...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4794 // Check if there is an API defined callback object which prohibits | 4814 // Check if there is an API defined callback object which prohibits |
| 4795 // callback overwriting in this object or its prototype chain. | 4815 // callback overwriting in this object or its prototype chain. |
| 4796 // This mechanism is needed for instance in a browser setting, where | 4816 // This mechanism is needed for instance in a browser setting, where |
| 4797 // certain accessors such as window.location should not be allowed | 4817 // certain accessors such as window.location should not be allowed |
| 4798 // to be overwritten because allowing overwriting could potentially | 4818 // to be overwritten because allowing overwriting could potentially |
| 4799 // cause security problems. | 4819 // cause security problems. |
| 4800 LookupResult callback_result(GetIsolate()); | 4820 LookupResult callback_result(GetIsolate()); |
| 4801 LookupCallbackProperty(name, &callback_result); | 4821 LookupCallbackProperty(name, &callback_result); |
| 4802 if (callback_result.IsFound()) { | 4822 if (callback_result.IsFound()) { |
| 4803 Object* obj = callback_result.GetCallbackObject(); | 4823 Object* obj = callback_result.GetCallbackObject(); |
| 4804 if (obj->IsAccessorInfo() && | 4824 if (obj->IsExecutableAccessorInfo()) { |
|
Sven Panne
2013/02/07 10:01:03
See comment above.
| |
| 4805 AccessorInfo::cast(obj)->prohibits_overwriting()) { | 4825 return !ExecutableAccessorInfo::cast(obj)->prohibits_overwriting(); |
| 4806 return false; | 4826 } |
| 4827 if (obj->IsDeclaredAccessorInfo()) { | |
| 4828 return !DeclaredAccessorInfo::cast(obj)->prohibits_overwriting(); | |
| 4807 } | 4829 } |
| 4808 } | 4830 } |
| 4809 | 4831 |
| 4810 return true; | 4832 return true; |
| 4811 } | 4833 } |
| 4812 | 4834 |
| 4813 | 4835 |
| 4814 MaybeObject* JSObject::SetElementCallback(uint32_t index, | 4836 MaybeObject* JSObject::SetElementCallback(uint32_t index, |
| 4815 Object* structure, | 4837 Object* structure, |
| 4816 PropertyAttributes attributes) { | 4838 PropertyAttributes attributes) { |
| (...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9726 | 9748 |
| 9727 | 9749 |
| 9728 MaybeObject* JSObject::GetElementWithCallback(Object* receiver, | 9750 MaybeObject* JSObject::GetElementWithCallback(Object* receiver, |
| 9729 Object* structure, | 9751 Object* structure, |
| 9730 uint32_t index, | 9752 uint32_t index, |
| 9731 Object* holder) { | 9753 Object* holder) { |
| 9732 Isolate* isolate = GetIsolate(); | 9754 Isolate* isolate = GetIsolate(); |
| 9733 ASSERT(!structure->IsForeign()); | 9755 ASSERT(!structure->IsForeign()); |
| 9734 | 9756 |
| 9735 // api style callbacks. | 9757 // api style callbacks. |
| 9736 if (structure->IsAccessorInfo()) { | 9758 if (structure->IsExecutableAccessorInfo()) { |
| 9737 Handle<AccessorInfo> data(AccessorInfo::cast(structure)); | 9759 Handle<ExecutableAccessorInfo> data( |
| 9760 ExecutableAccessorInfo::cast(structure)); | |
| 9738 Object* fun_obj = data->getter(); | 9761 Object* fun_obj = data->getter(); |
| 9739 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); | 9762 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); |
| 9740 if (call_fun == NULL) return isolate->heap()->undefined_value(); | 9763 if (call_fun == NULL) return isolate->heap()->undefined_value(); |
| 9741 HandleScope scope(isolate); | 9764 HandleScope scope(isolate); |
| 9742 Handle<JSObject> self(JSObject::cast(receiver)); | 9765 Handle<JSObject> self(JSObject::cast(receiver)); |
| 9743 Handle<JSObject> holder_handle(JSObject::cast(holder)); | 9766 Handle<JSObject> holder_handle(JSObject::cast(holder)); |
| 9744 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 9767 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
| 9745 Handle<String> key = isolate->factory()->NumberToString(number); | 9768 Handle<String> key = isolate->factory()->NumberToString(number); |
| 9746 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); | 9769 LOG(isolate, ApiNamedPropertyAccess("load", *self, *key)); |
| 9747 CustomArguments args(isolate, data->data(), *self, *holder_handle); | 9770 CustomArguments args(isolate, data->data(), *self, *holder_handle); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 9763 if (structure->IsAccessorPair()) { | 9786 if (structure->IsAccessorPair()) { |
| 9764 Object* getter = AccessorPair::cast(structure)->getter(); | 9787 Object* getter = AccessorPair::cast(structure)->getter(); |
| 9765 if (getter->IsSpecFunction()) { | 9788 if (getter->IsSpecFunction()) { |
| 9766 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 9789 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 9767 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); | 9790 return GetPropertyWithDefinedGetter(receiver, JSReceiver::cast(getter)); |
| 9768 } | 9791 } |
| 9769 // Getter is not a function. | 9792 // Getter is not a function. |
| 9770 return isolate->heap()->undefined_value(); | 9793 return isolate->heap()->undefined_value(); |
| 9771 } | 9794 } |
| 9772 | 9795 |
| 9796 if (structure->IsDeclaredAccessorInfo()) { | |
| 9797 // TODO(dcarney): Handle correctly. | |
| 9798 return isolate->heap()->undefined_value(); | |
| 9799 } | |
| 9800 | |
| 9773 UNREACHABLE(); | 9801 UNREACHABLE(); |
| 9774 return NULL; | 9802 return NULL; |
| 9775 } | 9803 } |
| 9776 | 9804 |
| 9777 | 9805 |
| 9778 MaybeObject* JSObject::SetElementWithCallback(Object* structure, | 9806 MaybeObject* JSObject::SetElementWithCallback(Object* structure, |
| 9779 uint32_t index, | 9807 uint32_t index, |
| 9780 Object* value, | 9808 Object* value, |
| 9781 JSObject* holder, | 9809 JSObject* holder, |
| 9782 StrictModeFlag strict_mode) { | 9810 StrictModeFlag strict_mode) { |
| 9783 Isolate* isolate = GetIsolate(); | 9811 Isolate* isolate = GetIsolate(); |
| 9784 HandleScope scope(isolate); | 9812 HandleScope scope(isolate); |
| 9785 | 9813 |
| 9786 // We should never get here to initialize a const with the hole | 9814 // We should never get here to initialize a const with the hole |
| 9787 // value since a const declaration would conflict with the setter. | 9815 // value since a const declaration would conflict with the setter. |
| 9788 ASSERT(!value->IsTheHole()); | 9816 ASSERT(!value->IsTheHole()); |
| 9789 Handle<Object> value_handle(value, isolate); | 9817 Handle<Object> value_handle(value, isolate); |
| 9790 | 9818 |
| 9791 // To accommodate both the old and the new api we switch on the | 9819 // To accommodate both the old and the new api we switch on the |
| 9792 // data structure used to store the callbacks. Eventually foreign | 9820 // data structure used to store the callbacks. Eventually foreign |
| 9793 // callbacks should be phased out. | 9821 // callbacks should be phased out. |
| 9794 ASSERT(!structure->IsForeign()); | 9822 ASSERT(!structure->IsForeign()); |
| 9795 | 9823 |
| 9796 if (structure->IsAccessorInfo()) { | 9824 if (structure->IsExecutableAccessorInfo()) { |
| 9797 // api style callbacks | 9825 // api style callbacks |
| 9798 Handle<JSObject> self(this); | 9826 Handle<JSObject> self(this); |
| 9799 Handle<JSObject> holder_handle(JSObject::cast(holder)); | 9827 Handle<JSObject> holder_handle(JSObject::cast(holder)); |
| 9800 Handle<AccessorInfo> data(AccessorInfo::cast(structure)); | 9828 Handle<ExecutableAccessorInfo> data( |
| 9829 ExecutableAccessorInfo::cast(structure)); | |
| 9801 Object* call_obj = data->setter(); | 9830 Object* call_obj = data->setter(); |
| 9802 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); | 9831 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); |
| 9803 if (call_fun == NULL) return value; | 9832 if (call_fun == NULL) return value; |
| 9804 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 9833 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
| 9805 Handle<String> key(isolate->factory()->NumberToString(number)); | 9834 Handle<String> key(isolate->factory()->NumberToString(number)); |
| 9806 LOG(isolate, ApiNamedPropertyAccess("store", *self, *key)); | 9835 LOG(isolate, ApiNamedPropertyAccess("store", *self, *key)); |
| 9807 CustomArguments args(isolate, data->data(), *self, *holder_handle); | 9836 CustomArguments args(isolate, data->data(), *self, *holder_handle); |
| 9808 v8::AccessorInfo info(args.end()); | 9837 v8::AccessorInfo info(args.end()); |
| 9809 { | 9838 { |
| 9810 // Leaving JavaScript. | 9839 // Leaving JavaScript. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 9828 } | 9857 } |
| 9829 Handle<Object> holder_handle(holder, isolate); | 9858 Handle<Object> holder_handle(holder, isolate); |
| 9830 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 9859 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); |
| 9831 Handle<Object> args[2] = { key, holder_handle }; | 9860 Handle<Object> args[2] = { key, holder_handle }; |
| 9832 return isolate->Throw( | 9861 return isolate->Throw( |
| 9833 *isolate->factory()->NewTypeError("no_setter_in_callback", | 9862 *isolate->factory()->NewTypeError("no_setter_in_callback", |
| 9834 HandleVector(args, 2))); | 9863 HandleVector(args, 2))); |
| 9835 } | 9864 } |
| 9836 } | 9865 } |
| 9837 | 9866 |
| 9867 // TODO(dcarney): Handle correctly. | |
| 9868 if (structure->IsDeclaredAccessorInfo()) return value; | |
| 9869 | |
| 9838 UNREACHABLE(); | 9870 UNREACHABLE(); |
| 9839 return NULL; | 9871 return NULL; |
| 9840 } | 9872 } |
| 9841 | 9873 |
| 9842 | 9874 |
| 9843 bool JSObject::HasFastArgumentsElements() { | 9875 bool JSObject::HasFastArgumentsElements() { |
| 9844 Heap* heap = GetHeap(); | 9876 Heap* heap = GetHeap(); |
| 9845 if (!elements()->IsFixedArray()) return false; | 9877 if (!elements()->IsFixedArray()) return false; |
| 9846 FixedArray* elements = FixedArray::cast(this->elements()); | 9878 FixedArray* elements = FixedArray::cast(this->elements()); |
| 9847 if (elements->map() != heap->non_strict_arguments_elements_map()) { | 9879 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); | 13924 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13893 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13925 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13894 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13926 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13895 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13927 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13896 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13928 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13897 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13929 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13898 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13930 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13899 } | 13931 } |
| 13900 | 13932 |
| 13901 } } // namespace v8::internal | 13933 } } // namespace v8::internal |
| OLD | NEW |