Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: src/objects.cc

Issue 12300018: Made Isolate a mandatory parameter for everything Handle-related. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Even less Isolate::Current Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->IsExecutableAccessorInfo()) { 183 if (structure->IsExecutableAccessorInfo()) {
184 ExecutableAccessorInfo* data = ExecutableAccessorInfo::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, isolate);
187 Handle<Object> receiver_handle(receiver); 187 Handle<Object> receiver_handle(receiver, isolate);
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 }
195 Object* fun_obj = data->getter(); 195 Object* fun_obj = data->getter();
196 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); 196 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
197 if (call_fun == NULL) return isolate->heap()->undefined_value(); 197 if (call_fun == NULL) return isolate->heap()->undefined_value();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 UNREACHABLE(); 235 UNREACHABLE();
236 return NULL; 236 return NULL;
237 } 237 }
238 238
239 239
240 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw, 240 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw,
241 String* name_raw) { 241 String* name_raw) {
242 Isolate* isolate = GetIsolate(); 242 Isolate* isolate = GetIsolate();
243 HandleScope scope(isolate); 243 HandleScope scope(isolate);
244 Handle<Object> receiver(receiver_raw); 244 Handle<Object> receiver(receiver_raw, isolate);
245 Handle<Object> name(name_raw); 245 Handle<Object> name(name_raw, isolate);
246 246
247 Handle<Object> args[] = { receiver, name }; 247 Handle<Object> args[] = { receiver, name };
248 Handle<Object> result = CallTrap( 248 Handle<Object> result = CallTrap(
249 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); 249 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args);
250 if (isolate->has_pending_exception()) return Failure::Exception(); 250 if (isolate->has_pending_exception()) return Failure::Exception();
251 251
252 return *result; 252 return *result;
253 } 253 }
254 254
255 255
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (!maybe->To<String>(&name)) return maybe; 299 if (!maybe->To<String>(&name)) return maybe;
300 return HasPropertyWithHandler(name); 300 return HasPropertyWithHandler(name);
301 } 301 }
302 302
303 303
304 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, 304 MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver,
305 JSReceiver* getter) { 305 JSReceiver* getter) {
306 Isolate* isolate = getter->GetIsolate(); 306 Isolate* isolate = getter->GetIsolate();
307 HandleScope scope(isolate); 307 HandleScope scope(isolate);
308 Handle<JSReceiver> fun(getter); 308 Handle<JSReceiver> fun(getter);
309 Handle<Object> self(receiver); 309 Handle<Object> self(receiver, isolate);
310 #ifdef ENABLE_DEBUGGER_SUPPORT 310 #ifdef ENABLE_DEBUGGER_SUPPORT
311 Debug* debug = isolate->debug(); 311 Debug* debug = isolate->debug();
312 // Handle stepping into a getter if step into is active. 312 // Handle stepping into a getter if step into is active.
313 // TODO(rossberg): should this apply to getters that are function proxies? 313 // TODO(rossberg): should this apply to getters that are function proxies?
314 if (debug->StepInActive() && fun->IsJSFunction()) { 314 if (debug->StepInActive() && fun->IsJSFunction()) {
315 debug->HandleStepIn( 315 debug->HandleStepIn(
316 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false); 316 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false);
317 } 317 }
318 #endif 318 #endif
319 319
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 Handle<Object> old_value) { 1755 Handle<Object> old_value) {
1756 Isolate* isolate = object->GetIsolate(); 1756 Isolate* isolate = object->GetIsolate();
1757 HandleScope scope(isolate); 1757 HandleScope scope(isolate);
1758 Handle<String> type = isolate->factory()->LookupUtf8Symbol(type_str); 1758 Handle<String> type = isolate->factory()->LookupUtf8Symbol(type_str);
1759 if (object->IsJSGlobalObject()) { 1759 if (object->IsJSGlobalObject()) {
1760 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); 1760 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate);
1761 } 1761 }
1762 Handle<Object> args[] = { type, object, name, old_value }; 1762 Handle<Object> args[] = { type, object, name, old_value };
1763 bool threw; 1763 bool threw;
1764 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()), 1764 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()),
1765 Handle<Object>(isolate->heap()->undefined_value()), 1765 Handle<Object>(isolate->heap()->undefined_value(), isolate),
Michael Starzinger 2013/02/25 10:50:58 Just use "isolate->factory()->undefined_value()" h
Sven Panne 2013/02/25 14:44:43 Done.
1766 old_value->IsTheHole() ? 3 : 4, args, 1766 old_value->IsTheHole() ? 3 : 4, args,
1767 &threw); 1767 &threw);
1768 ASSERT(!threw); 1768 ASSERT(!threw);
1769 } 1769 }
1770 1770
1771 1771
1772 void JSObject::DeliverChangeRecords(Isolate* isolate) { 1772 void JSObject::DeliverChangeRecords(Isolate* isolate) {
1773 ASSERT(isolate->observer_delivery_pending()); 1773 ASSERT(isolate->observer_delivery_pending());
1774 bool threw = false; 1774 bool threw = false;
1775 Execution::Call( 1775 Execution::Call(
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 MaybeObject* obj = (callback->setter)(this, value, callback->data); 2006 MaybeObject* obj = (callback->setter)(this, value, callback->data);
2007 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 2007 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
2008 if (obj->IsFailure()) return obj; 2008 if (obj->IsFailure()) return obj;
2009 return *value_handle; 2009 return *value_handle;
2010 } 2010 }
2011 2011
2012 if (structure->IsExecutableAccessorInfo()) { 2012 if (structure->IsExecutableAccessorInfo()) {
2013 // api style callbacks 2013 // api style callbacks
2014 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure); 2014 ExecutableAccessorInfo* data = ExecutableAccessorInfo::cast(structure);
2015 if (!data->IsCompatibleReceiver(this)) { 2015 if (!data->IsCompatibleReceiver(this)) {
2016 Handle<Object> name_handle(name); 2016 Handle<Object> name_handle(name, isolate);
2017 Handle<Object> receiver_handle(this); 2017 Handle<Object> receiver_handle(this, isolate);
2018 Handle<Object> args[2] = { name_handle, receiver_handle }; 2018 Handle<Object> args[2] = { name_handle, receiver_handle };
2019 Handle<Object> error = 2019 Handle<Object> error =
2020 isolate->factory()->NewTypeError("incompatible_method_receiver", 2020 isolate->factory()->NewTypeError("incompatible_method_receiver",
2021 HandleVector(args, 2021 HandleVector(args,
2022 ARRAY_SIZE(args))); 2022 ARRAY_SIZE(args)));
2023 return isolate->Throw(*error); 2023 return isolate->Throw(*error);
2024 } 2024 }
2025 Object* call_obj = data->setter(); 2025 Object* call_obj = data->setter();
2026 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); 2026 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
2027 if (call_fun == NULL) return value; 2027 if (call_fun == NULL) return value;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 case NONEXISTENT: 2176 case NONEXISTENT:
2177 UNREACHABLE(); 2177 UNREACHABLE();
2178 break; 2178 break;
2179 } 2179 }
2180 } 2180 }
2181 2181
2182 // If we get here with *done true, we have encountered a read-only property. 2182 // If we get here with *done true, we have encountered a read-only property.
2183 if (!FLAG_es5_readonly) *done = false; 2183 if (!FLAG_es5_readonly) *done = false;
2184 if (*done) { 2184 if (*done) {
2185 if (strict_mode == kNonStrictMode) return value; 2185 if (strict_mode == kNonStrictMode) return value;
2186 Handle<Object> args[] = { Handle<Object>(name), Handle<Object>(this)}; 2186 Handle<Object> args[] = { Handle<Object>(name, isolate),
2187 Handle<Object>(this, isolate)};
2187 return isolate->Throw(*isolate->factory()->NewTypeError( 2188 return isolate->Throw(*isolate->factory()->NewTypeError(
2188 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)))); 2189 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))));
2189 } 2190 }
2190 return heap->the_hole_value(); 2191 return heap->the_hole_value();
2191 } 2192 }
2192 2193
2193 2194
2194 enum RightTrimMode { FROM_GC, FROM_MUTATOR }; 2195 enum RightTrimMode { FROM_GC, FROM_MUTATOR };
2195 2196
2196 2197
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 } 2562 }
2562 default: { 2563 default: {
2563 break; 2564 break;
2564 } 2565 }
2565 } 2566 }
2566 } 2567 }
2567 } 2568 }
2568 2569
2569 Isolate* isolate = GetIsolate(); 2570 Isolate* isolate = GetIsolate();
2570 HandleScope scope(isolate); 2571 HandleScope scope(isolate);
2571 Handle<Object> value_handle(value); 2572 Handle<Object> value_handle(value, isolate);
2572 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); 2573 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
2573 return *value_handle; 2574 return *value_handle;
2574 } 2575 }
2575 2576
2576 2577
2577 MaybeObject* JSReceiver::SetProperty(LookupResult* result, 2578 MaybeObject* JSReceiver::SetProperty(LookupResult* result,
2578 String* key, 2579 String* key,
2579 Object* value, 2580 Object* value,
2580 PropertyAttributes attributes, 2581 PropertyAttributes attributes,
2581 StrictModeFlag strict_mode, 2582 StrictModeFlag strict_mode,
2582 JSReceiver::StoreFromKeyed store_mode) { 2583 JSReceiver::StoreFromKeyed store_mode) {
2583 if (result->IsHandler()) { 2584 if (result->IsHandler()) {
2584 return result->proxy()->SetPropertyWithHandler( 2585 return result->proxy()->SetPropertyWithHandler(
2585 this, key, value, attributes, strict_mode); 2586 this, key, value, attributes, strict_mode);
2586 } else { 2587 } else {
2587 return JSObject::cast(this)->SetPropertyForResult( 2588 return JSObject::cast(this)->SetPropertyForResult(
2588 result, key, value, attributes, strict_mode, store_mode); 2589 result, key, value, attributes, strict_mode, store_mode);
2589 } 2590 }
2590 } 2591 }
2591 2592
2592 2593
2593 bool JSProxy::HasPropertyWithHandler(String* name_raw) { 2594 bool JSProxy::HasPropertyWithHandler(String* name_raw) {
2594 Isolate* isolate = GetIsolate(); 2595 Isolate* isolate = GetIsolate();
2595 HandleScope scope(isolate); 2596 HandleScope scope(isolate);
2596 Handle<Object> receiver(this); 2597 Handle<Object> receiver(this, isolate);
2597 Handle<Object> name(name_raw); 2598 Handle<Object> name(name_raw, isolate);
2598 2599
2599 Handle<Object> args[] = { name }; 2600 Handle<Object> args[] = { name };
2600 Handle<Object> result = CallTrap( 2601 Handle<Object> result = CallTrap(
2601 "has", isolate->derived_has_trap(), ARRAY_SIZE(args), args); 2602 "has", isolate->derived_has_trap(), ARRAY_SIZE(args), args);
2602 if (isolate->has_pending_exception()) return false; 2603 if (isolate->has_pending_exception()) return false;
2603 2604
2604 return result->ToBoolean()->IsTrue(); 2605 return result->ToBoolean()->IsTrue();
2605 } 2606 }
2606 2607
2607 2608
2608 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandler( 2609 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyWithHandler(
2609 JSReceiver* receiver_raw, 2610 JSReceiver* receiver_raw,
2610 String* name_raw, 2611 String* name_raw,
2611 Object* value_raw, 2612 Object* value_raw,
2612 PropertyAttributes attributes, 2613 PropertyAttributes attributes,
2613 StrictModeFlag strict_mode) { 2614 StrictModeFlag strict_mode) {
2614 Isolate* isolate = GetIsolate(); 2615 Isolate* isolate = GetIsolate();
2615 HandleScope scope(isolate); 2616 HandleScope scope(isolate);
2616 Handle<JSReceiver> receiver(receiver_raw); 2617 Handle<JSReceiver> receiver(receiver_raw);
2617 Handle<Object> name(name_raw); 2618 Handle<Object> name(name_raw, isolate);
2618 Handle<Object> value(value_raw); 2619 Handle<Object> value(value_raw, isolate);
2619 2620
2620 Handle<Object> args[] = { receiver, name, value }; 2621 Handle<Object> args[] = { receiver, name, value };
2621 CallTrap("set", isolate->derived_set_trap(), ARRAY_SIZE(args), args); 2622 CallTrap("set", isolate->derived_set_trap(), ARRAY_SIZE(args), args);
2622 if (isolate->has_pending_exception()) return Failure::Exception(); 2623 if (isolate->has_pending_exception()) return Failure::Exception();
2623 2624
2624 return *value; 2625 return *value;
2625 } 2626 }
2626 2627
2627 2628
2628 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler( 2629 MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler(
2629 JSReceiver* receiver_raw, 2630 JSReceiver* receiver_raw,
2630 String* name_raw, 2631 String* name_raw,
2631 Object* value_raw, 2632 Object* value_raw,
2632 PropertyAttributes attributes, 2633 PropertyAttributes attributes,
2633 StrictModeFlag strict_mode, 2634 StrictModeFlag strict_mode,
2634 bool* done) { 2635 bool* done) {
2635 Isolate* isolate = GetIsolate(); 2636 Isolate* isolate = GetIsolate();
2636 Handle<JSProxy> proxy(this); 2637 Handle<JSProxy> proxy(this);
2637 Handle<JSReceiver> receiver(receiver_raw); 2638 Handle<JSReceiver> receiver(receiver_raw);
2638 Handle<String> name(name_raw); 2639 Handle<String> name(name_raw);
2639 Handle<Object> value(value_raw); 2640 Handle<Object> value(value_raw, isolate);
2640 Handle<Object> handler(this->handler()); // Trap might morph proxy. 2641 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy.
2641 2642
2642 *done = true; // except where redefined... 2643 *done = true; // except where redefined...
2643 Handle<Object> args[] = { name }; 2644 Handle<Object> args[] = { name };
2644 Handle<Object> result = proxy->CallTrap( 2645 Handle<Object> result = proxy->CallTrap(
2645 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); 2646 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args);
2646 if (isolate->has_pending_exception()) return Failure::Exception(); 2647 if (isolate->has_pending_exception()) return Failure::Exception();
2647 2648
2648 if (result->IsUndefined()) { 2649 if (result->IsUndefined()) {
2649 *done = false; 2650 *done = false;
2650 return GetHeap()->the_hole_value(); 2651 return GetHeap()->the_hole_value();
2651 } 2652 }
2652 2653
2653 // Emulate [[GetProperty]] semantics for proxies. 2654 // Emulate [[GetProperty]] semantics for proxies.
2654 bool has_pending_exception; 2655 bool has_pending_exception;
2655 Handle<Object> argv[] = { result }; 2656 Handle<Object> argv[] = { result };
2656 Handle<Object> desc = 2657 Handle<Object> desc =
2657 Execution::Call(isolate->to_complete_property_descriptor(), result, 2658 Execution::Call(isolate->to_complete_property_descriptor(), result,
2658 ARRAY_SIZE(argv), argv, &has_pending_exception); 2659 ARRAY_SIZE(argv), argv, &has_pending_exception);
2659 if (has_pending_exception) return Failure::Exception(); 2660 if (has_pending_exception) return Failure::Exception();
2660 2661
2661 // [[GetProperty]] requires to check that all properties are configurable. 2662 // [[GetProperty]] requires to check that all properties are configurable.
2662 Handle<String> configurable_name = isolate->factory()->LookupOneByteSymbol( 2663 Handle<String> configurable_name = isolate->factory()->LookupOneByteSymbol(
2663 STATIC_ASCII_VECTOR("configurable_")); 2664 STATIC_ASCII_VECTOR("configurable_"));
2664 Handle<Object> configurable( 2665 Handle<Object> configurable(
2665 v8::internal::GetProperty(desc, configurable_name)); 2666 v8::internal::GetProperty(isolate, desc, configurable_name));
2666 ASSERT(!isolate->has_pending_exception()); 2667 ASSERT(!isolate->has_pending_exception());
2667 ASSERT(configurable->IsTrue() || configurable->IsFalse()); 2668 ASSERT(configurable->IsTrue() || configurable->IsFalse());
2668 if (configurable->IsFalse()) { 2669 if (configurable->IsFalse()) {
2669 Handle<String> trap = 2670 Handle<String> trap =
2670 isolate->factory()->LookupOneByteSymbol( 2671 isolate->factory()->LookupOneByteSymbol(
2671 STATIC_ASCII_VECTOR("getPropertyDescriptor")); 2672 STATIC_ASCII_VECTOR("getPropertyDescriptor"));
2672 Handle<Object> args[] = { handler, trap, name }; 2673 Handle<Object> args[] = { handler, trap, name };
2673 Handle<Object> error = isolate->factory()->NewTypeError( 2674 Handle<Object> error = isolate->factory()->NewTypeError(
2674 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); 2675 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
2675 return isolate->Throw(*error); 2676 return isolate->Throw(*error);
2676 } 2677 }
2677 ASSERT(configurable->IsTrue()); 2678 ASSERT(configurable->IsTrue());
2678 2679
2679 // Check for DataDescriptor. 2680 // Check for DataDescriptor.
2680 Handle<String> hasWritable_name = 2681 Handle<String> hasWritable_name =
2681 isolate->factory()->LookupOneByteSymbol( 2682 isolate->factory()->LookupOneByteSymbol(
2682 STATIC_ASCII_VECTOR("hasWritable_")); 2683 STATIC_ASCII_VECTOR("hasWritable_"));
2683 Handle<Object> hasWritable(v8::internal::GetProperty(desc, hasWritable_name)); 2684 Handle<Object> hasWritable(
2685 v8::internal::GetProperty(isolate, desc, hasWritable_name));
2684 ASSERT(!isolate->has_pending_exception()); 2686 ASSERT(!isolate->has_pending_exception());
2685 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse()); 2687 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse());
2686 if (hasWritable->IsTrue()) { 2688 if (hasWritable->IsTrue()) {
2687 Handle<String> writable_name = 2689 Handle<String> writable_name =
2688 isolate->factory()->LookupOneByteSymbol( 2690 isolate->factory()->LookupOneByteSymbol(
2689 STATIC_ASCII_VECTOR("writable_")); 2691 STATIC_ASCII_VECTOR("writable_"));
2690 Handle<Object> writable(v8::internal::GetProperty(desc, writable_name)); 2692 Handle<Object> writable(
2693 v8::internal::GetProperty(isolate, desc, writable_name));
2691 ASSERT(!isolate->has_pending_exception()); 2694 ASSERT(!isolate->has_pending_exception());
2692 ASSERT(writable->IsTrue() || writable->IsFalse()); 2695 ASSERT(writable->IsTrue() || writable->IsFalse());
2693 *done = writable->IsFalse(); 2696 *done = writable->IsFalse();
2694 if (!*done) return GetHeap()->the_hole_value(); 2697 if (!*done) return GetHeap()->the_hole_value();
2695 if (strict_mode == kNonStrictMode) return *value; 2698 if (strict_mode == kNonStrictMode) return *value;
2696 Handle<Object> args[] = { name, receiver }; 2699 Handle<Object> args[] = { name, receiver };
2697 Handle<Object> error = isolate->factory()->NewTypeError( 2700 Handle<Object> error = isolate->factory()->NewTypeError(
2698 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))); 2701 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)));
2699 return isolate->Throw(*error); 2702 return isolate->Throw(*error);
2700 } 2703 }
2701 2704
2702 // We have an AccessorDescriptor. 2705 // We have an AccessorDescriptor.
2703 Handle<String> set_name = isolate->factory()->LookupOneByteSymbol( 2706 Handle<String> set_name = isolate->factory()->LookupOneByteSymbol(
2704 STATIC_ASCII_VECTOR("set_")); 2707 STATIC_ASCII_VECTOR("set_"));
2705 Handle<Object> setter(v8::internal::GetProperty(desc, set_name)); 2708 Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_name));
2706 ASSERT(!isolate->has_pending_exception()); 2709 ASSERT(!isolate->has_pending_exception());
2707 if (!setter->IsUndefined()) { 2710 if (!setter->IsUndefined()) {
2708 // TODO(rossberg): nicer would be to cast to some JSCallable here... 2711 // TODO(rossberg): nicer would be to cast to some JSCallable here...
2709 return receiver->SetPropertyWithDefinedSetter( 2712 return receiver->SetPropertyWithDefinedSetter(
2710 JSReceiver::cast(*setter), *value); 2713 JSReceiver::cast(*setter), *value);
2711 } 2714 }
2712 2715
2713 if (strict_mode == kNonStrictMode) return *value; 2716 if (strict_mode == kNonStrictMode) return *value;
2714 Handle<Object> args2[] = { name, proxy }; 2717 Handle<Object> args2[] = { name, proxy };
2715 Handle<Object> error = isolate->factory()->NewTypeError( 2718 Handle<Object> error = isolate->factory()->NewTypeError(
2716 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); 2719 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2)));
2717 return isolate->Throw(*error); 2720 return isolate->Throw(*error);
2718 } 2721 }
2719 2722
2720 2723
2721 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( 2724 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler(
2722 String* name_raw, DeleteMode mode) { 2725 String* name_raw, DeleteMode mode) {
2723 Isolate* isolate = GetIsolate(); 2726 Isolate* isolate = GetIsolate();
2724 HandleScope scope(isolate); 2727 HandleScope scope(isolate);
2725 Handle<JSProxy> receiver(this); 2728 Handle<JSProxy> receiver(this);
2726 Handle<Object> name(name_raw); 2729 Handle<Object> name(name_raw, isolate);
2727 2730
2728 Handle<Object> args[] = { name }; 2731 Handle<Object> args[] = { name };
2729 Handle<Object> result = CallTrap( 2732 Handle<Object> result = CallTrap(
2730 "delete", Handle<Object>(), ARRAY_SIZE(args), args); 2733 "delete", Handle<Object>(), ARRAY_SIZE(args), args);
2731 if (isolate->has_pending_exception()) return Failure::Exception(); 2734 if (isolate->has_pending_exception()) return Failure::Exception();
2732 2735
2733 Object* bool_result = result->ToBoolean(); 2736 Object* bool_result = result->ToBoolean();
2734 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { 2737 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) {
2735 Handle<Object> handler(receiver->handler()); 2738 Handle<Object> handler(receiver->handler(), isolate);
2736 Handle<String> trap_name = isolate->factory()->LookupOneByteSymbol( 2739 Handle<String> trap_name = isolate->factory()->LookupOneByteSymbol(
2737 STATIC_ASCII_VECTOR("delete")); 2740 STATIC_ASCII_VECTOR("delete"));
2738 Handle<Object> args[] = { handler, trap_name }; 2741 Handle<Object> args[] = { handler, trap_name };
2739 Handle<Object> error = isolate->factory()->NewTypeError( 2742 Handle<Object> error = isolate->factory()->NewTypeError(
2740 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); 2743 "handler_failed", HandleVector(args, ARRAY_SIZE(args)));
2741 isolate->Throw(*error); 2744 isolate->Throw(*error);
2742 return Failure::Exception(); 2745 return Failure::Exception();
2743 } 2746 }
2744 return bool_result; 2747 return bool_result;
2745 } 2748 }
2746 2749
2747 2750
2748 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler( 2751 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler(
2749 uint32_t index, 2752 uint32_t index,
2750 DeleteMode mode) { 2753 DeleteMode mode) {
2751 Isolate* isolate = GetIsolate(); 2754 Isolate* isolate = GetIsolate();
2752 HandleScope scope(isolate); 2755 HandleScope scope(isolate);
2753 Handle<String> name = isolate->factory()->Uint32ToString(index); 2756 Handle<String> name = isolate->factory()->Uint32ToString(index);
2754 return JSProxy::DeletePropertyWithHandler(*name, mode); 2757 return JSProxy::DeletePropertyWithHandler(*name, mode);
2755 } 2758 }
2756 2759
2757 2760
2758 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( 2761 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler(
2759 JSReceiver* receiver_raw, 2762 JSReceiver* receiver_raw,
2760 String* name_raw) { 2763 String* name_raw) {
2761 Isolate* isolate = GetIsolate(); 2764 Isolate* isolate = GetIsolate();
2762 HandleScope scope(isolate); 2765 HandleScope scope(isolate);
2763 Handle<JSProxy> proxy(this); 2766 Handle<JSProxy> proxy(this);
2764 Handle<Object> handler(this->handler()); // Trap might morph proxy. 2767 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy.
2765 Handle<JSReceiver> receiver(receiver_raw); 2768 Handle<JSReceiver> receiver(receiver_raw);
2766 Handle<Object> name(name_raw); 2769 Handle<Object> name(name_raw, isolate);
2767 2770
2768 Handle<Object> args[] = { name }; 2771 Handle<Object> args[] = { name };
2769 Handle<Object> result = CallTrap( 2772 Handle<Object> result = CallTrap(
2770 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); 2773 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args);
2771 if (isolate->has_pending_exception()) return NONE; 2774 if (isolate->has_pending_exception()) return NONE;
2772 2775
2773 if (result->IsUndefined()) return ABSENT; 2776 if (result->IsUndefined()) return ABSENT;
2774 2777
2775 bool has_pending_exception; 2778 bool has_pending_exception;
2776 Handle<Object> argv[] = { result }; 2779 Handle<Object> argv[] = { result };
2777 Handle<Object> desc = 2780 Handle<Object> desc =
2778 Execution::Call(isolate->to_complete_property_descriptor(), result, 2781 Execution::Call(isolate->to_complete_property_descriptor(), result,
2779 ARRAY_SIZE(argv), argv, &has_pending_exception); 2782 ARRAY_SIZE(argv), argv, &has_pending_exception);
2780 if (has_pending_exception) return NONE; 2783 if (has_pending_exception) return NONE;
2781 2784
2782 // Convert result to PropertyAttributes. 2785 // Convert result to PropertyAttributes.
2783 Handle<String> enum_n = isolate->factory()->LookupOneByteSymbol( 2786 Handle<String> enum_n = isolate->factory()->LookupOneByteSymbol(
2784 STATIC_ASCII_VECTOR("enumerable")); 2787 STATIC_ASCII_VECTOR("enumerable"));
2785 Handle<Object> enumerable(v8::internal::GetProperty(desc, enum_n)); 2788 Handle<Object> enumerable(v8::internal::GetProperty(isolate, desc, enum_n));
2786 if (isolate->has_pending_exception()) return NONE; 2789 if (isolate->has_pending_exception()) return NONE;
2787 Handle<String> conf_n = isolate->factory()->LookupOneByteSymbol( 2790 Handle<String> conf_n = isolate->factory()->LookupOneByteSymbol(
2788 STATIC_ASCII_VECTOR("configurable")); 2791 STATIC_ASCII_VECTOR("configurable"));
2789 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_n)); 2792 Handle<Object> configurable(v8::internal::GetProperty(isolate, desc, conf_n));
2790 if (isolate->has_pending_exception()) return NONE; 2793 if (isolate->has_pending_exception()) return NONE;
2791 Handle<String> writ_n = isolate->factory()->LookupOneByteSymbol( 2794 Handle<String> writ_n = isolate->factory()->LookupOneByteSymbol(
2792 STATIC_ASCII_VECTOR("writable")); 2795 STATIC_ASCII_VECTOR("writable"));
2793 Handle<Object> writable(v8::internal::GetProperty(desc, writ_n)); 2796 Handle<Object> writable(v8::internal::GetProperty(isolate, desc, writ_n));
2794 if (isolate->has_pending_exception()) return NONE; 2797 if (isolate->has_pending_exception()) return NONE;
2795 2798
2796 if (configurable->IsFalse()) { 2799 if (configurable->IsFalse()) {
2797 Handle<String> trap = isolate->factory()->LookupOneByteSymbol( 2800 Handle<String> trap = isolate->factory()->LookupOneByteSymbol(
2798 STATIC_ASCII_VECTOR("getPropertyDescriptor")); 2801 STATIC_ASCII_VECTOR("getPropertyDescriptor"));
2799 Handle<Object> args[] = { handler, trap, name }; 2802 Handle<Object> args[] = { handler, trap, name };
2800 Handle<Object> error = isolate->factory()->NewTypeError( 2803 Handle<Object> error = isolate->factory()->NewTypeError(
2801 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); 2804 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
2802 isolate->Throw(*error); 2805 isolate->Throw(*error);
2803 return NONE; 2806 return NONE;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 isolate->factory()->SetIdentityHash(new_self, Smi::cast(hash)); 2849 isolate->factory()->SetIdentityHash(new_self, Smi::cast(hash));
2847 } 2850 }
2848 } 2851 }
2849 2852
2850 2853
2851 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name, 2854 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name,
2852 Handle<Object> derived, 2855 Handle<Object> derived,
2853 int argc, 2856 int argc,
2854 Handle<Object> argv[]) { 2857 Handle<Object> argv[]) {
2855 Isolate* isolate = GetIsolate(); 2858 Isolate* isolate = GetIsolate();
2856 Handle<Object> handler(this->handler()); 2859 Handle<Object> handler(this->handler(), isolate);
2857 2860
2858 Handle<String> trap_name = isolate->factory()->LookupUtf8Symbol(name); 2861 Handle<String> trap_name = isolate->factory()->LookupUtf8Symbol(name);
2859 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); 2862 Handle<Object> trap(v8::internal::GetProperty(isolate, handler, trap_name));
2860 if (isolate->has_pending_exception()) return trap; 2863 if (isolate->has_pending_exception()) return trap;
2861 2864
2862 if (trap->IsUndefined()) { 2865 if (trap->IsUndefined()) {
2863 if (derived.is_null()) { 2866 if (derived.is_null()) {
2864 Handle<Object> args[] = { handler, trap_name }; 2867 Handle<Object> args[] = { handler, trap_name };
2865 Handle<Object> error = isolate->factory()->NewTypeError( 2868 Handle<Object> error = isolate->factory()->NewTypeError(
2866 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); 2869 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
2867 isolate->Throw(*error); 2870 isolate->Throw(*error);
2868 return Handle<Object>(); 2871 return Handle<Object>();
2869 } 2872 }
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4147 if (IsAccessCheckNeeded() && 4150 if (IsAccessCheckNeeded() &&
4148 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 4151 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
4149 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 4152 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
4150 return isolate->heap()->false_value(); 4153 return isolate->heap()->false_value();
4151 } 4154 }
4152 4155
4153 if (IsStringObjectWithCharacterAt(index)) { 4156 if (IsStringObjectWithCharacterAt(index)) {
4154 if (mode == STRICT_DELETION) { 4157 if (mode == STRICT_DELETION) {
4155 // Deleting a non-configurable property in strict mode. 4158 // Deleting a non-configurable property in strict mode.
4156 HandleScope scope(isolate); 4159 HandleScope scope(isolate);
4157 Handle<Object> holder(this); 4160 Handle<Object> holder(this, isolate);
4158 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); 4161 Handle<Object> name = isolate->factory()->NewNumberFromUint(index);
4159 Handle<Object> args[2] = { name, holder }; 4162 Handle<Object> args[2] = { name, holder };
4160 Handle<Object> error = 4163 Handle<Object> error =
4161 isolate->factory()->NewTypeError("strict_delete_property", 4164 isolate->factory()->NewTypeError("strict_delete_property",
4162 HandleVector(args, 2)); 4165 HandleVector(args, 2));
4163 return isolate->Throw(*error); 4166 return isolate->Throw(*error);
4164 } 4167 }
4165 return isolate->heap()->false_value(); 4168 return isolate->heap()->false_value();
4166 } 4169 }
4167 4170
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 } 4243 }
4241 4244
4242 LookupResult lookup(isolate); 4245 LookupResult lookup(isolate);
4243 LocalLookup(name, &lookup, true); 4246 LocalLookup(name, &lookup, true);
4244 if (!lookup.IsFound()) return isolate->heap()->true_value(); 4247 if (!lookup.IsFound()) return isolate->heap()->true_value();
4245 // Ignore attributes if forcing a deletion. 4248 // Ignore attributes if forcing a deletion.
4246 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { 4249 if (lookup.IsDontDelete() && mode != FORCE_DELETION) {
4247 if (mode == STRICT_DELETION) { 4250 if (mode == STRICT_DELETION) {
4248 // Deleting a non-configurable property in strict mode. 4251 // Deleting a non-configurable property in strict mode.
4249 HandleScope scope(isolate); 4252 HandleScope scope(isolate);
4250 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; 4253 Handle<Object> args[2] = { Handle<Object>(name, isolate),
4254 Handle<Object>(this, isolate) };
4251 return isolate->Throw(*isolate->factory()->NewTypeError( 4255 return isolate->Throw(*isolate->factory()->NewTypeError(
4252 "strict_delete_property", HandleVector(args, 2))); 4256 "strict_delete_property", HandleVector(args, 2)));
4253 } 4257 }
4254 return isolate->heap()->false_value(); 4258 return isolate->heap()->false_value();
4255 } 4259 }
4256 4260
4257 // From this point on everything needs to be handlified. 4261 // From this point on everything needs to be handlified.
4258 HandleScope scope(isolate); 4262 HandleScope scope(isolate);
4259 Handle<JSObject> self(this); 4263 Handle<JSObject> self(this);
4260 Handle<String> hname(name); 4264 Handle<String> hname(name);
4261 4265
4262 Handle<Object> old_value(isolate->heap()->the_hole_value()); 4266 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate);
Michael Starzinger 2013/02/25 10:50:58 Just use "Handle<Object> old_value = isolate->fact
Sven Panne 2013/02/25 14:44:43 Done.
4263 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 4267 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
4264 if (is_observed && lookup.IsDataProperty()) { 4268 if (is_observed && lookup.IsDataProperty()) {
4265 old_value = Object::GetProperty(self, hname); 4269 old_value = Object::GetProperty(self, hname);
4266 } 4270 }
4267 MaybeObject* result; 4271 MaybeObject* result;
4268 4272
4269 // Check for interceptor. 4273 // Check for interceptor.
4270 if (lookup.IsInterceptor()) { 4274 if (lookup.IsInterceptor()) {
4271 // Skip interceptor if forcing a deletion. 4275 // Skip interceptor if forcing a deletion.
4272 if (mode == FORCE_DELETION) { 4276 if (mode == FORCE_DELETION) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4459 if (IsJSGlobalProxy()) { 4463 if (IsJSGlobalProxy()) {
4460 Object* proto = GetPrototype(); 4464 Object* proto = GetPrototype();
4461 if (proto->IsNull()) return this; 4465 if (proto->IsNull()) return this;
4462 ASSERT(proto->IsJSGlobalObject()); 4466 ASSERT(proto->IsJSGlobalObject());
4463 return JSObject::cast(proto)->PreventExtensions(); 4467 return JSObject::cast(proto)->PreventExtensions();
4464 } 4468 }
4465 4469
4466 // It's not possible to seal objects with external array elements 4470 // It's not possible to seal objects with external array elements
4467 if (HasExternalArrayElements()) { 4471 if (HasExternalArrayElements()) {
4468 HandleScope scope(isolate); 4472 HandleScope scope(isolate);
4469 Handle<Object> object(this); 4473 Handle<Object> object(this, isolate);
4470 Handle<Object> error = 4474 Handle<Object> error =
4471 isolate->factory()->NewTypeError( 4475 isolate->factory()->NewTypeError(
4472 "cant_prevent_ext_external_array_elements", 4476 "cant_prevent_ext_external_array_elements",
4473 HandleVector(&object, 1)); 4477 HandleVector(&object, 1));
4474 return isolate->Throw(*error); 4478 return isolate->Throw(*error);
4475 } 4479 }
4476 4480
4477 // If there are fast elements we normalize. 4481 // If there are fast elements we normalize.
4478 SeededNumberDictionary* dictionary = NULL; 4482 SeededNumberDictionary* dictionary = NULL;
4479 { MaybeObject* maybe = NormalizeElements(); 4483 { MaybeObject* maybe = NormalizeElements();
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4927 4931
4928 // Try to flatten before operating on the string. 4932 // Try to flatten before operating on the string.
4929 name_raw->TryFlatten(); 4933 name_raw->TryFlatten();
4930 4934
4931 if (!CanSetCallback(name_raw)) return isolate->heap()->undefined_value(); 4935 if (!CanSetCallback(name_raw)) return isolate->heap()->undefined_value();
4932 4936
4933 // From this point on everything needs to be handlified. 4937 // From this point on everything needs to be handlified.
4934 HandleScope scope(isolate); 4938 HandleScope scope(isolate);
4935 Handle<JSObject> self(this); 4939 Handle<JSObject> self(this);
4936 Handle<String> name(name_raw); 4940 Handle<String> name(name_raw);
4937 Handle<Object> getter(getter_raw); 4941 Handle<Object> getter(getter_raw, isolate);
4938 Handle<Object> setter(setter_raw); 4942 Handle<Object> setter(setter_raw, isolate);
4939 4943
4940 uint32_t index = 0; 4944 uint32_t index = 0;
4941 bool is_element = name->AsArrayIndex(&index); 4945 bool is_element = name->AsArrayIndex(&index);
4942 4946
4943 Handle<Object> old_value = isolate->factory()->the_hole_value(); 4947 Handle<Object> old_value = isolate->factory()->the_hole_value();
4944 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 4948 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
4945 bool preexists = false; 4949 bool preexists = false;
4946 if (is_observed) { 4950 if (is_observed) {
4947 if (is_element) { 4951 if (is_element) {
4948 preexists = HasLocalElement(index); 4952 preexists = HasLocalElement(index);
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
6170 set_cache(new_cache); 6174 set_cache(new_cache);
6171 return this; 6175 return this;
6172 } 6176 }
6173 6177
6174 6178
6175 Handle<Object> PolymorphicCodeCache::Lookup(MapHandleList* maps, 6179 Handle<Object> PolymorphicCodeCache::Lookup(MapHandleList* maps,
6176 Code::Flags flags) { 6180 Code::Flags flags) {
6177 if (!cache()->IsUndefined()) { 6181 if (!cache()->IsUndefined()) {
6178 PolymorphicCodeCacheHashTable* hash_table = 6182 PolymorphicCodeCacheHashTable* hash_table =
6179 PolymorphicCodeCacheHashTable::cast(cache()); 6183 PolymorphicCodeCacheHashTable::cast(cache());
6180 return Handle<Object>(hash_table->Lookup(maps, flags)); 6184 return Handle<Object>(hash_table->Lookup(maps, flags), GetIsolate());
6181 } else { 6185 } else {
6182 return GetIsolate()->factory()->undefined_value(); 6186 return GetIsolate()->factory()->undefined_value();
6183 } 6187 }
6184 } 6188 }
6185 6189
6186 6190
6187 // Despite their name, object of this class are not stored in the actual 6191 // Despite their name, object of this class are not stored in the actual
6188 // hash table; instead they're temporarily used for lookups. It is therefore 6192 // hash table; instead they're temporarily used for lookups. It is therefore
6189 // safe to have a weak (non-owning) pointer to a MapList as a member field. 6193 // safe to have a weak (non-owning) pointer to a MapList as a member field.
6190 class PolymorphicCodeCacheHashTableKey : public HashTableKey { 6194 class PolymorphicCodeCacheHashTableKey : public HashTableKey {
(...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after
9378 // We should never end in here with a pixel or external array. 9382 // We should never end in here with a pixel or external array.
9379 ASSERT(AllowsSetElementsLength()); 9383 ASSERT(AllowsSetElementsLength());
9380 if (!(FLAG_harmony_observation && map()->is_observed())) 9384 if (!(FLAG_harmony_observation && map()->is_observed()))
9381 return GetElementsAccessor()->SetLength(this, len); 9385 return GetElementsAccessor()->SetLength(this, len);
9382 9386
9383 Isolate* isolate = GetIsolate(); 9387 Isolate* isolate = GetIsolate();
9384 HandleScope scope(isolate); 9388 HandleScope scope(isolate);
9385 Handle<JSArray> self(this); 9389 Handle<JSArray> self(this);
9386 List<Handle<String> > indices; 9390 List<Handle<String> > indices;
9387 List<Handle<Object> > old_values; 9391 List<Handle<Object> > old_values;
9388 Handle<Object> old_length_handle(self->length()); 9392 Handle<Object> old_length_handle(self->length(), isolate);
9389 Handle<Object> new_length_handle(len); 9393 Handle<Object> new_length_handle(len, isolate);
9390 uint32_t old_length = 0; 9394 uint32_t old_length = 0;
9391 CHECK(old_length_handle->ToArrayIndex(&old_length)); 9395 CHECK(old_length_handle->ToArrayIndex(&old_length));
9392 uint32_t new_length = 0; 9396 uint32_t new_length = 0;
9393 if (!new_length_handle->ToArrayIndex(&new_length)) 9397 if (!new_length_handle->ToArrayIndex(&new_length))
9394 return Failure::InternalError(); 9398 return Failure::InternalError();
9395 9399
9396 // Observed arrays should always be in dictionary mode; 9400 // Observed arrays should always be in dictionary mode;
9397 // if they were in fast mode, the below is slower than necessary 9401 // if they were in fast mode, the below is slower than necessary
9398 // as it iterates over the array backing store multiple times. 9402 // as it iterates over the array backing store multiple times.
9399 ASSERT(self->HasDictionaryElements()); 9403 ASSERT(self->HasDictionaryElements());
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
9829 VMState state(isolate, EXTERNAL); 9833 VMState state(isolate, EXTERNAL);
9830 call_fun(v8::Utils::ToLocal(key), 9834 call_fun(v8::Utils::ToLocal(key),
9831 v8::Utils::ToLocal(value_handle), 9835 v8::Utils::ToLocal(value_handle),
9832 info); 9836 info);
9833 } 9837 }
9834 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 9838 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
9835 return *value_handle; 9839 return *value_handle;
9836 } 9840 }
9837 9841
9838 if (structure->IsAccessorPair()) { 9842 if (structure->IsAccessorPair()) {
9839 Handle<Object> setter(AccessorPair::cast(structure)->setter()); 9843 Handle<Object> setter(AccessorPair::cast(structure)->setter(), isolate);
9840 if (setter->IsSpecFunction()) { 9844 if (setter->IsSpecFunction()) {
9841 // TODO(rossberg): nicer would be to cast to some JSCallable here... 9845 // TODO(rossberg): nicer would be to cast to some JSCallable here...
9842 return SetPropertyWithDefinedSetter(JSReceiver::cast(*setter), value); 9846 return SetPropertyWithDefinedSetter(JSReceiver::cast(*setter), value);
9843 } else { 9847 } else {
9844 if (strict_mode == kNonStrictMode) { 9848 if (strict_mode == kNonStrictMode) {
9845 return value; 9849 return value;
9846 } 9850 }
9847 Handle<Object> holder_handle(holder, isolate); 9851 Handle<Object> holder_handle(holder, isolate);
9848 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); 9852 Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
9849 Handle<Object> args[2] = { key, holder_handle }; 9853 Handle<Object> args[2] = { key, holder_handle };
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
10023 MaybeObject* JSObject::SetDictionaryElement(uint32_t index, 10027 MaybeObject* JSObject::SetDictionaryElement(uint32_t index,
10024 Object* value_raw, 10028 Object* value_raw,
10025 PropertyAttributes attributes, 10029 PropertyAttributes attributes,
10026 StrictModeFlag strict_mode, 10030 StrictModeFlag strict_mode,
10027 bool check_prototype, 10031 bool check_prototype,
10028 SetPropertyMode set_mode) { 10032 SetPropertyMode set_mode) {
10029 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); 10033 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements());
10030 Isolate* isolate = GetIsolate(); 10034 Isolate* isolate = GetIsolate();
10031 Heap* heap = isolate->heap(); 10035 Heap* heap = isolate->heap();
10032 Handle<JSObject> self(this); 10036 Handle<JSObject> self(this);
10033 Handle<Object> value(value_raw); 10037 Handle<Object> value(value_raw, isolate);
10034 10038
10035 // Insert element in the dictionary. 10039 // Insert element in the dictionary.
10036 Handle<FixedArray> elements(FixedArray::cast(this->elements())); 10040 Handle<FixedArray> elements(FixedArray::cast(this->elements()));
10037 bool is_arguments = 10041 bool is_arguments =
10038 (elements->map() == heap->non_strict_arguments_elements_map()); 10042 (elements->map() == heap->non_strict_arguments_elements_map());
10039 Handle<SeededNumberDictionary> dictionary(is_arguments 10043 Handle<SeededNumberDictionary> dictionary(is_arguments
10040 ? SeededNumberDictionary::cast(elements->get(1)) 10044 ? SeededNumberDictionary::cast(elements->get(1))
10041 : SeededNumberDictionary::cast(*elements)); 10045 : SeededNumberDictionary::cast(*elements));
10042 10046
10043 int entry = dictionary->FindEntry(index); 10047 int entry = dictionary->FindEntry(index);
10044 if (entry != SeededNumberDictionary::kNotFound) { 10048 if (entry != SeededNumberDictionary::kNotFound) {
10045 Object* element = dictionary->ValueAt(entry); 10049 Object* element = dictionary->ValueAt(entry);
10046 PropertyDetails details = dictionary->DetailsAt(entry); 10050 PropertyDetails details = dictionary->DetailsAt(entry);
10047 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) { 10051 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) {
10048 return SetElementWithCallback(element, index, *value, this, strict_mode); 10052 return SetElementWithCallback(element, index, *value, this, strict_mode);
10049 } else { 10053 } else {
10050 dictionary->UpdateMaxNumberKey(index); 10054 dictionary->UpdateMaxNumberKey(index);
10051 // If a value has not been initialized we allow writing to it even if it 10055 // If a value has not been initialized we allow writing to it even if it
10052 // is read-only (a declared const that has not been initialized). If a 10056 // is read-only (a declared const that has not been initialized). If a
10053 // value is being defined we skip attribute checks completely. 10057 // value is being defined we skip attribute checks completely.
10054 if (set_mode == DEFINE_PROPERTY) { 10058 if (set_mode == DEFINE_PROPERTY) {
10055 details = PropertyDetails( 10059 details = PropertyDetails(
10056 attributes, NORMAL, details.dictionary_index()); 10060 attributes, NORMAL, details.dictionary_index());
10057 dictionary->DetailsAtPut(entry, details); 10061 dictionary->DetailsAtPut(entry, details);
10058 } else if (details.IsReadOnly() && !element->IsTheHole()) { 10062 } else if (details.IsReadOnly() && !element->IsTheHole()) {
10059 if (strict_mode == kNonStrictMode) { 10063 if (strict_mode == kNonStrictMode) {
10060 return isolate->heap()->undefined_value(); 10064 return isolate->heap()->undefined_value();
10061 } else { 10065 } else {
10062 Handle<Object> holder(this); 10066 Handle<Object> holder(this, isolate);
10063 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 10067 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
10064 Handle<Object> args[2] = { number, holder }; 10068 Handle<Object> args[2] = { number, holder };
10065 Handle<Object> error = 10069 Handle<Object> error =
10066 isolate->factory()->NewTypeError("strict_read_only_property", 10070 isolate->factory()->NewTypeError("strict_read_only_property",
10067 HandleVector(args, 2)); 10071 HandleVector(args, 2));
10068 return isolate->Throw(*error); 10072 return isolate->Throw(*error);
10069 } 10073 }
10070 } 10074 }
10071 // Elements of the arguments object in slow mode might be slow aliases. 10075 // Elements of the arguments object in slow mode might be slow aliases.
10072 if (is_arguments && element->IsAliasedArgumentsEntry()) { 10076 if (is_arguments && element->IsAliasedArgumentsEntry()) {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
10360 if (!(FLAG_harmony_observation && map()->is_observed())) { 10364 if (!(FLAG_harmony_observation && map()->is_observed())) {
10361 return HasIndexedInterceptor() 10365 return HasIndexedInterceptor()
10362 ? SetElementWithInterceptor( 10366 ? SetElementWithInterceptor(
10363 index, value_raw, attributes, strict_mode, check_prototype, set_mode) 10367 index, value_raw, attributes, strict_mode, check_prototype, set_mode)
10364 : SetElementWithoutInterceptor( 10368 : SetElementWithoutInterceptor(
10365 index, value_raw, attributes, strict_mode, check_prototype, set_mode); 10369 index, value_raw, attributes, strict_mode, check_prototype, set_mode);
10366 } 10370 }
10367 10371
10368 // From here on, everything has to be handlified. 10372 // From here on, everything has to be handlified.
10369 Handle<JSObject> self(this); 10373 Handle<JSObject> self(this);
10370 Handle<Object> value(value_raw); 10374 Handle<Object> value(value_raw, isolate);
10371 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index); 10375 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index);
10372 Handle<Object> old_value = isolate->factory()->the_hole_value(); 10376 Handle<Object> old_value = isolate->factory()->the_hole_value();
10373 Handle<Object> old_length; 10377 Handle<Object> old_length;
10374 10378
10375 if (old_attributes != ABSENT) { 10379 if (old_attributes != ABSENT) {
10376 if (self->GetLocalElementAccessorPair(index) == NULL) 10380 if (self->GetLocalElementAccessorPair(index) == NULL)
10377 old_value = Object::GetElement(self, index); 10381 old_value = Object::GetElement(self, index);
10378 } else if (self->IsJSArray()) { 10382 } else if (self->IsJSArray()) {
10379 // Store old array length in case adding an element grows the array. 10383 // Store old array length in case adding an element grows the array.
10380 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate); 10384 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate);
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
10977 } 10981 }
10978 10982
10979 10983
10980 MaybeObject* JSObject::GetPropertyWithInterceptor( 10984 MaybeObject* JSObject::GetPropertyWithInterceptor(
10981 Object* receiver, 10985 Object* receiver,
10982 String* name, 10986 String* name,
10983 PropertyAttributes* attributes) { 10987 PropertyAttributes* attributes) {
10984 Isolate* isolate = GetIsolate(); 10988 Isolate* isolate = GetIsolate();
10985 InterceptorInfo* interceptor = GetNamedInterceptor(); 10989 InterceptorInfo* interceptor = GetNamedInterceptor();
10986 HandleScope scope(isolate); 10990 HandleScope scope(isolate);
10987 Handle<Object> receiver_handle(receiver); 10991 Handle<Object> receiver_handle(receiver, isolate);
10988 Handle<JSObject> holder_handle(this); 10992 Handle<JSObject> holder_handle(this);
10989 Handle<String> name_handle(name); 10993 Handle<String> name_handle(name);
10990 10994
10991 if (!interceptor->getter()->IsUndefined()) { 10995 if (!interceptor->getter()->IsUndefined()) {
10992 v8::NamedPropertyGetter getter = 10996 v8::NamedPropertyGetter getter =
10993 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter()); 10997 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
10994 LOG(isolate, 10998 LOG(isolate,
10995 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); 10999 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
10996 CustomArguments args(isolate, interceptor->data(), receiver, this); 11000 CustomArguments args(isolate, interceptor->data(), receiver, this);
10997 v8::AccessorInfo info(args.end()); 11001 v8::AccessorInfo info(args.end());
(...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after
13568 // Return the break point info object if any. 13572 // Return the break point info object if any.
13569 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); 13573 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value();
13570 return BreakPointInfo::cast(break_points()->get(index)); 13574 return BreakPointInfo::cast(break_points()->get(index));
13571 } 13575 }
13572 13576
13573 13577
13574 // Clear a break point at the specified code position. 13578 // Clear a break point at the specified code position.
13575 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, 13579 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
13576 int code_position, 13580 int code_position,
13577 Handle<Object> break_point_object) { 13581 Handle<Object> break_point_object) {
13578 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); 13582 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
13583 Isolate::Current());
13579 if (break_point_info->IsUndefined()) return; 13584 if (break_point_info->IsUndefined()) return;
13580 BreakPointInfo::ClearBreakPoint( 13585 BreakPointInfo::ClearBreakPoint(
13581 Handle<BreakPointInfo>::cast(break_point_info), 13586 Handle<BreakPointInfo>::cast(break_point_info),
13582 break_point_object); 13587 break_point_object);
13583 } 13588 }
13584 13589
13585 13590
13586 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, 13591 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
13587 int code_position, 13592 int code_position,
13588 int source_position, 13593 int source_position,
13589 int statement_position, 13594 int statement_position,
13590 Handle<Object> break_point_object) { 13595 Handle<Object> break_point_object) {
13591 Isolate* isolate = Isolate::Current(); 13596 Isolate* isolate = Isolate::Current();
13592 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); 13597 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
13598 isolate);
13593 if (!break_point_info->IsUndefined()) { 13599 if (!break_point_info->IsUndefined()) {
13594 BreakPointInfo::SetBreakPoint( 13600 BreakPointInfo::SetBreakPoint(
13595 Handle<BreakPointInfo>::cast(break_point_info), 13601 Handle<BreakPointInfo>::cast(break_point_info),
13596 break_point_object); 13602 break_point_object);
13597 return; 13603 return;
13598 } 13604 }
13599 13605
13600 // Adding a new break point for a code position which did not have any 13606 // Adding a new break point for a code position which did not have any
13601 // break points before. Try to find a free slot. 13607 // break points before. Try to find a free slot.
13602 int index = kNoBreakPointInfo; 13608 int index = kNoBreakPointInfo;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
13923 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13929 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13924 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13930 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13925 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13931 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13926 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13932 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13927 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13933 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13928 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13934 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13929 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13935 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13930 } 13936 }
13931 13937
13932 } } // namespace v8::internal 13938 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698