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

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: Fixed CreateCode calls. Be nicer to MIPS. Created 7 years, 9 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
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 isolate->factory()->undefined_value(),
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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 if (IsAccessCheckNeeded() && 4151 if (IsAccessCheckNeeded() &&
4149 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 4152 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
4150 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 4153 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
4151 return isolate->heap()->false_value(); 4154 return isolate->heap()->false_value();
4152 } 4155 }
4153 4156
4154 if (IsStringObjectWithCharacterAt(index)) { 4157 if (IsStringObjectWithCharacterAt(index)) {
4155 if (mode == STRICT_DELETION) { 4158 if (mode == STRICT_DELETION) {
4156 // Deleting a non-configurable property in strict mode. 4159 // Deleting a non-configurable property in strict mode.
4157 HandleScope scope(isolate); 4160 HandleScope scope(isolate);
4158 Handle<Object> holder(this); 4161 Handle<Object> holder(this, isolate);
4159 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); 4162 Handle<Object> name = isolate->factory()->NewNumberFromUint(index);
4160 Handle<Object> args[2] = { name, holder }; 4163 Handle<Object> args[2] = { name, holder };
4161 Handle<Object> error = 4164 Handle<Object> error =
4162 isolate->factory()->NewTypeError("strict_delete_property", 4165 isolate->factory()->NewTypeError("strict_delete_property",
4163 HandleVector(args, 2)); 4166 HandleVector(args, 2));
4164 return isolate->Throw(*error); 4167 return isolate->Throw(*error);
4165 } 4168 }
4166 return isolate->heap()->false_value(); 4169 return isolate->heap()->false_value();
4167 } 4170 }
4168 4171
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
4241 } 4244 }
4242 4245
4243 LookupResult lookup(isolate); 4246 LookupResult lookup(isolate);
4244 LocalLookup(name, &lookup, true); 4247 LocalLookup(name, &lookup, true);
4245 if (!lookup.IsFound()) return isolate->heap()->true_value(); 4248 if (!lookup.IsFound()) return isolate->heap()->true_value();
4246 // Ignore attributes if forcing a deletion. 4249 // Ignore attributes if forcing a deletion.
4247 if (lookup.IsDontDelete() && mode != FORCE_DELETION) { 4250 if (lookup.IsDontDelete() && mode != FORCE_DELETION) {
4248 if (mode == STRICT_DELETION) { 4251 if (mode == STRICT_DELETION) {
4249 // Deleting a non-configurable property in strict mode. 4252 // Deleting a non-configurable property in strict mode.
4250 HandleScope scope(isolate); 4253 HandleScope scope(isolate);
4251 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; 4254 Handle<Object> args[2] = { Handle<Object>(name, isolate),
4255 Handle<Object>(this, isolate) };
4252 return isolate->Throw(*isolate->factory()->NewTypeError( 4256 return isolate->Throw(*isolate->factory()->NewTypeError(
4253 "strict_delete_property", HandleVector(args, 2))); 4257 "strict_delete_property", HandleVector(args, 2)));
4254 } 4258 }
4255 return isolate->heap()->false_value(); 4259 return isolate->heap()->false_value();
4256 } 4260 }
4257 4261
4258 // From this point on everything needs to be handlified. 4262 // From this point on everything needs to be handlified.
4259 HandleScope scope(isolate); 4263 HandleScope scope(isolate);
4260 Handle<JSObject> self(this); 4264 Handle<JSObject> self(this);
4261 Handle<String> hname(name); 4265 Handle<String> hname(name);
4262 4266
4263 Handle<Object> old_value(isolate->heap()->the_hole_value()); 4267 Handle<Object> old_value = isolate->factory()->the_hole_value();
4264 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 4268 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
4265 if (is_observed && lookup.IsDataProperty()) { 4269 if (is_observed && lookup.IsDataProperty()) {
4266 old_value = Object::GetProperty(self, hname); 4270 old_value = Object::GetProperty(self, hname);
4267 } 4271 }
4268 MaybeObject* result; 4272 MaybeObject* result;
4269 4273
4270 // Check for interceptor. 4274 // Check for interceptor.
4271 if (lookup.IsInterceptor()) { 4275 if (lookup.IsInterceptor()) {
4272 // Skip interceptor if forcing a deletion. 4276 // Skip interceptor if forcing a deletion.
4273 if (mode == FORCE_DELETION) { 4277 if (mode == FORCE_DELETION) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4460 if (IsJSGlobalProxy()) { 4464 if (IsJSGlobalProxy()) {
4461 Object* proto = GetPrototype(); 4465 Object* proto = GetPrototype();
4462 if (proto->IsNull()) return this; 4466 if (proto->IsNull()) return this;
4463 ASSERT(proto->IsJSGlobalObject()); 4467 ASSERT(proto->IsJSGlobalObject());
4464 return JSObject::cast(proto)->PreventExtensions(); 4468 return JSObject::cast(proto)->PreventExtensions();
4465 } 4469 }
4466 4470
4467 // It's not possible to seal objects with external array elements 4471 // It's not possible to seal objects with external array elements
4468 if (HasExternalArrayElements()) { 4472 if (HasExternalArrayElements()) {
4469 HandleScope scope(isolate); 4473 HandleScope scope(isolate);
4470 Handle<Object> object(this); 4474 Handle<Object> object(this, isolate);
4471 Handle<Object> error = 4475 Handle<Object> error =
4472 isolate->factory()->NewTypeError( 4476 isolate->factory()->NewTypeError(
4473 "cant_prevent_ext_external_array_elements", 4477 "cant_prevent_ext_external_array_elements",
4474 HandleVector(&object, 1)); 4478 HandleVector(&object, 1));
4475 return isolate->Throw(*error); 4479 return isolate->Throw(*error);
4476 } 4480 }
4477 4481
4478 // If there are fast elements we normalize. 4482 // If there are fast elements we normalize.
4479 SeededNumberDictionary* dictionary = NULL; 4483 SeededNumberDictionary* dictionary = NULL;
4480 { MaybeObject* maybe = NormalizeElements(); 4484 { MaybeObject* maybe = NormalizeElements();
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4928 4932
4929 // Try to flatten before operating on the string. 4933 // Try to flatten before operating on the string.
4930 name_raw->TryFlatten(); 4934 name_raw->TryFlatten();
4931 4935
4932 if (!CanSetCallback(name_raw)) return isolate->heap()->undefined_value(); 4936 if (!CanSetCallback(name_raw)) return isolate->heap()->undefined_value();
4933 4937
4934 // From this point on everything needs to be handlified. 4938 // From this point on everything needs to be handlified.
4935 HandleScope scope(isolate); 4939 HandleScope scope(isolate);
4936 Handle<JSObject> self(this); 4940 Handle<JSObject> self(this);
4937 Handle<String> name(name_raw); 4941 Handle<String> name(name_raw);
4938 Handle<Object> getter(getter_raw); 4942 Handle<Object> getter(getter_raw, isolate);
4939 Handle<Object> setter(setter_raw); 4943 Handle<Object> setter(setter_raw, isolate);
4940 4944
4941 uint32_t index = 0; 4945 uint32_t index = 0;
4942 bool is_element = name->AsArrayIndex(&index); 4946 bool is_element = name->AsArrayIndex(&index);
4943 4947
4944 Handle<Object> old_value = isolate->factory()->the_hole_value(); 4948 Handle<Object> old_value = isolate->factory()->the_hole_value();
4945 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 4949 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
4946 bool preexists = false; 4950 bool preexists = false;
4947 if (is_observed) { 4951 if (is_observed) {
4948 if (is_element) { 4952 if (is_element) {
4949 preexists = HasLocalElement(index); 4953 preexists = HasLocalElement(index);
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
6172 set_cache(new_cache); 6176 set_cache(new_cache);
6173 return this; 6177 return this;
6174 } 6178 }
6175 6179
6176 6180
6177 Handle<Object> PolymorphicCodeCache::Lookup(MapHandleList* maps, 6181 Handle<Object> PolymorphicCodeCache::Lookup(MapHandleList* maps,
6178 Code::Flags flags) { 6182 Code::Flags flags) {
6179 if (!cache()->IsUndefined()) { 6183 if (!cache()->IsUndefined()) {
6180 PolymorphicCodeCacheHashTable* hash_table = 6184 PolymorphicCodeCacheHashTable* hash_table =
6181 PolymorphicCodeCacheHashTable::cast(cache()); 6185 PolymorphicCodeCacheHashTable::cast(cache());
6182 return Handle<Object>(hash_table->Lookup(maps, flags)); 6186 return Handle<Object>(hash_table->Lookup(maps, flags), GetIsolate());
6183 } else { 6187 } else {
6184 return GetIsolate()->factory()->undefined_value(); 6188 return GetIsolate()->factory()->undefined_value();
6185 } 6189 }
6186 } 6190 }
6187 6191
6188 6192
6189 // Despite their name, object of this class are not stored in the actual 6193 // Despite their name, object of this class are not stored in the actual
6190 // hash table; instead they're temporarily used for lookups. It is therefore 6194 // hash table; instead they're temporarily used for lookups. It is therefore
6191 // safe to have a weak (non-owning) pointer to a MapList as a member field. 6195 // safe to have a weak (non-owning) pointer to a MapList as a member field.
6192 class PolymorphicCodeCacheHashTableKey : public HashTableKey { 6196 class PolymorphicCodeCacheHashTableKey : public HashTableKey {
(...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after
9380 // We should never end in here with a pixel or external array. 9384 // We should never end in here with a pixel or external array.
9381 ASSERT(AllowsSetElementsLength()); 9385 ASSERT(AllowsSetElementsLength());
9382 if (!(FLAG_harmony_observation && map()->is_observed())) 9386 if (!(FLAG_harmony_observation && map()->is_observed()))
9383 return GetElementsAccessor()->SetLength(this, len); 9387 return GetElementsAccessor()->SetLength(this, len);
9384 9388
9385 Isolate* isolate = GetIsolate(); 9389 Isolate* isolate = GetIsolate();
9386 HandleScope scope(isolate); 9390 HandleScope scope(isolate);
9387 Handle<JSArray> self(this); 9391 Handle<JSArray> self(this);
9388 List<Handle<String> > indices; 9392 List<Handle<String> > indices;
9389 List<Handle<Object> > old_values; 9393 List<Handle<Object> > old_values;
9390 Handle<Object> old_length_handle(self->length()); 9394 Handle<Object> old_length_handle(self->length(), isolate);
9391 Handle<Object> new_length_handle(len); 9395 Handle<Object> new_length_handle(len, isolate);
9392 uint32_t old_length = 0; 9396 uint32_t old_length = 0;
9393 CHECK(old_length_handle->ToArrayIndex(&old_length)); 9397 CHECK(old_length_handle->ToArrayIndex(&old_length));
9394 uint32_t new_length = 0; 9398 uint32_t new_length = 0;
9395 if (!new_length_handle->ToArrayIndex(&new_length)) 9399 if (!new_length_handle->ToArrayIndex(&new_length))
9396 return Failure::InternalError(); 9400 return Failure::InternalError();
9397 9401
9398 // Observed arrays should always be in dictionary mode; 9402 // Observed arrays should always be in dictionary mode;
9399 // if they were in fast mode, the below is slower than necessary 9403 // if they were in fast mode, the below is slower than necessary
9400 // as it iterates over the array backing store multiple times. 9404 // as it iterates over the array backing store multiple times.
9401 ASSERT(self->HasDictionaryElements()); 9405 ASSERT(self->HasDictionaryElements());
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
9896 VMState state(isolate, EXTERNAL); 9900 VMState state(isolate, EXTERNAL);
9897 call_fun(v8::Utils::ToLocal(key), 9901 call_fun(v8::Utils::ToLocal(key),
9898 v8::Utils::ToLocal(value_handle), 9902 v8::Utils::ToLocal(value_handle),
9899 info); 9903 info);
9900 } 9904 }
9901 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 9905 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
9902 return *value_handle; 9906 return *value_handle;
9903 } 9907 }
9904 9908
9905 if (structure->IsAccessorPair()) { 9909 if (structure->IsAccessorPair()) {
9906 Handle<Object> setter(AccessorPair::cast(structure)->setter()); 9910 Handle<Object> setter(AccessorPair::cast(structure)->setter(), isolate);
9907 if (setter->IsSpecFunction()) { 9911 if (setter->IsSpecFunction()) {
9908 // TODO(rossberg): nicer would be to cast to some JSCallable here... 9912 // TODO(rossberg): nicer would be to cast to some JSCallable here...
9909 return SetPropertyWithDefinedSetter(JSReceiver::cast(*setter), value); 9913 return SetPropertyWithDefinedSetter(JSReceiver::cast(*setter), value);
9910 } else { 9914 } else {
9911 if (strict_mode == kNonStrictMode) { 9915 if (strict_mode == kNonStrictMode) {
9912 return value; 9916 return value;
9913 } 9917 }
9914 Handle<Object> holder_handle(holder, isolate); 9918 Handle<Object> holder_handle(holder, isolate);
9915 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); 9919 Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
9916 Handle<Object> args[2] = { key, holder_handle }; 9920 Handle<Object> args[2] = { key, holder_handle };
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
10090 MaybeObject* JSObject::SetDictionaryElement(uint32_t index, 10094 MaybeObject* JSObject::SetDictionaryElement(uint32_t index,
10091 Object* value_raw, 10095 Object* value_raw,
10092 PropertyAttributes attributes, 10096 PropertyAttributes attributes,
10093 StrictModeFlag strict_mode, 10097 StrictModeFlag strict_mode,
10094 bool check_prototype, 10098 bool check_prototype,
10095 SetPropertyMode set_mode) { 10099 SetPropertyMode set_mode) {
10096 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements()); 10100 ASSERT(HasDictionaryElements() || HasDictionaryArgumentsElements());
10097 Isolate* isolate = GetIsolate(); 10101 Isolate* isolate = GetIsolate();
10098 Heap* heap = isolate->heap(); 10102 Heap* heap = isolate->heap();
10099 Handle<JSObject> self(this); 10103 Handle<JSObject> self(this);
10100 Handle<Object> value(value_raw); 10104 Handle<Object> value(value_raw, isolate);
10101 10105
10102 // Insert element in the dictionary. 10106 // Insert element in the dictionary.
10103 Handle<FixedArray> elements(FixedArray::cast(this->elements())); 10107 Handle<FixedArray> elements(FixedArray::cast(this->elements()));
10104 bool is_arguments = 10108 bool is_arguments =
10105 (elements->map() == heap->non_strict_arguments_elements_map()); 10109 (elements->map() == heap->non_strict_arguments_elements_map());
10106 Handle<SeededNumberDictionary> dictionary(is_arguments 10110 Handle<SeededNumberDictionary> dictionary(is_arguments
10107 ? SeededNumberDictionary::cast(elements->get(1)) 10111 ? SeededNumberDictionary::cast(elements->get(1))
10108 : SeededNumberDictionary::cast(*elements)); 10112 : SeededNumberDictionary::cast(*elements));
10109 10113
10110 int entry = dictionary->FindEntry(index); 10114 int entry = dictionary->FindEntry(index);
10111 if (entry != SeededNumberDictionary::kNotFound) { 10115 if (entry != SeededNumberDictionary::kNotFound) {
10112 Object* element = dictionary->ValueAt(entry); 10116 Object* element = dictionary->ValueAt(entry);
10113 PropertyDetails details = dictionary->DetailsAt(entry); 10117 PropertyDetails details = dictionary->DetailsAt(entry);
10114 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) { 10118 if (details.type() == CALLBACKS && set_mode == SET_PROPERTY) {
10115 return SetElementWithCallback(element, index, *value, this, strict_mode); 10119 return SetElementWithCallback(element, index, *value, this, strict_mode);
10116 } else { 10120 } else {
10117 dictionary->UpdateMaxNumberKey(index); 10121 dictionary->UpdateMaxNumberKey(index);
10118 // If a value has not been initialized we allow writing to it even if it 10122 // If a value has not been initialized we allow writing to it even if it
10119 // is read-only (a declared const that has not been initialized). If a 10123 // is read-only (a declared const that has not been initialized). If a
10120 // value is being defined we skip attribute checks completely. 10124 // value is being defined we skip attribute checks completely.
10121 if (set_mode == DEFINE_PROPERTY) { 10125 if (set_mode == DEFINE_PROPERTY) {
10122 details = PropertyDetails( 10126 details = PropertyDetails(
10123 attributes, NORMAL, details.dictionary_index()); 10127 attributes, NORMAL, details.dictionary_index());
10124 dictionary->DetailsAtPut(entry, details); 10128 dictionary->DetailsAtPut(entry, details);
10125 } else if (details.IsReadOnly() && !element->IsTheHole()) { 10129 } else if (details.IsReadOnly() && !element->IsTheHole()) {
10126 if (strict_mode == kNonStrictMode) { 10130 if (strict_mode == kNonStrictMode) {
10127 return isolate->heap()->undefined_value(); 10131 return isolate->heap()->undefined_value();
10128 } else { 10132 } else {
10129 Handle<Object> holder(this); 10133 Handle<Object> holder(this, isolate);
10130 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 10134 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
10131 Handle<Object> args[2] = { number, holder }; 10135 Handle<Object> args[2] = { number, holder };
10132 Handle<Object> error = 10136 Handle<Object> error =
10133 isolate->factory()->NewTypeError("strict_read_only_property", 10137 isolate->factory()->NewTypeError("strict_read_only_property",
10134 HandleVector(args, 2)); 10138 HandleVector(args, 2));
10135 return isolate->Throw(*error); 10139 return isolate->Throw(*error);
10136 } 10140 }
10137 } 10141 }
10138 // Elements of the arguments object in slow mode might be slow aliases. 10142 // Elements of the arguments object in slow mode might be slow aliases.
10139 if (is_arguments && element->IsAliasedArgumentsEntry()) { 10143 if (is_arguments && element->IsAliasedArgumentsEntry()) {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
10427 if (!(FLAG_harmony_observation && map()->is_observed())) { 10431 if (!(FLAG_harmony_observation && map()->is_observed())) {
10428 return HasIndexedInterceptor() 10432 return HasIndexedInterceptor()
10429 ? SetElementWithInterceptor( 10433 ? SetElementWithInterceptor(
10430 index, value_raw, attributes, strict_mode, check_prototype, set_mode) 10434 index, value_raw, attributes, strict_mode, check_prototype, set_mode)
10431 : SetElementWithoutInterceptor( 10435 : SetElementWithoutInterceptor(
10432 index, value_raw, attributes, strict_mode, check_prototype, set_mode); 10436 index, value_raw, attributes, strict_mode, check_prototype, set_mode);
10433 } 10437 }
10434 10438
10435 // From here on, everything has to be handlified. 10439 // From here on, everything has to be handlified.
10436 Handle<JSObject> self(this); 10440 Handle<JSObject> self(this);
10437 Handle<Object> value(value_raw); 10441 Handle<Object> value(value_raw, isolate);
10438 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index); 10442 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index);
10439 Handle<Object> old_value = isolate->factory()->the_hole_value(); 10443 Handle<Object> old_value = isolate->factory()->the_hole_value();
10440 Handle<Object> old_length; 10444 Handle<Object> old_length;
10441 10445
10442 if (old_attributes != ABSENT) { 10446 if (old_attributes != ABSENT) {
10443 if (self->GetLocalElementAccessorPair(index) == NULL) 10447 if (self->GetLocalElementAccessorPair(index) == NULL)
10444 old_value = Object::GetElement(self, index); 10448 old_value = Object::GetElement(self, index);
10445 } else if (self->IsJSArray()) { 10449 } else if (self->IsJSArray()) {
10446 // Store old array length in case adding an element grows the array. 10450 // Store old array length in case adding an element grows the array.
10447 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate); 10451 old_length = handle(Handle<JSArray>::cast(self)->length(), isolate);
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
11044 } 11048 }
11045 11049
11046 11050
11047 MaybeObject* JSObject::GetPropertyWithInterceptor( 11051 MaybeObject* JSObject::GetPropertyWithInterceptor(
11048 Object* receiver, 11052 Object* receiver,
11049 String* name, 11053 String* name,
11050 PropertyAttributes* attributes) { 11054 PropertyAttributes* attributes) {
11051 Isolate* isolate = GetIsolate(); 11055 Isolate* isolate = GetIsolate();
11052 InterceptorInfo* interceptor = GetNamedInterceptor(); 11056 InterceptorInfo* interceptor = GetNamedInterceptor();
11053 HandleScope scope(isolate); 11057 HandleScope scope(isolate);
11054 Handle<Object> receiver_handle(receiver); 11058 Handle<Object> receiver_handle(receiver, isolate);
11055 Handle<JSObject> holder_handle(this); 11059 Handle<JSObject> holder_handle(this);
11056 Handle<String> name_handle(name); 11060 Handle<String> name_handle(name);
11057 11061
11058 if (!interceptor->getter()->IsUndefined()) { 11062 if (!interceptor->getter()->IsUndefined()) {
11059 v8::NamedPropertyGetter getter = 11063 v8::NamedPropertyGetter getter =
11060 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter()); 11064 v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
11061 LOG(isolate, 11065 LOG(isolate,
11062 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); 11066 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
11063 CustomArguments args(isolate, interceptor->data(), receiver, this); 11067 CustomArguments args(isolate, interceptor->data(), receiver, this);
11064 v8::AccessorInfo info(args.end()); 11068 v8::AccessorInfo info(args.end());
(...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after
13635 // Return the break point info object if any. 13639 // Return the break point info object if any.
13636 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); 13640 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value();
13637 return BreakPointInfo::cast(break_points()->get(index)); 13641 return BreakPointInfo::cast(break_points()->get(index));
13638 } 13642 }
13639 13643
13640 13644
13641 // Clear a break point at the specified code position. 13645 // Clear a break point at the specified code position.
13642 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, 13646 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
13643 int code_position, 13647 int code_position,
13644 Handle<Object> break_point_object) { 13648 Handle<Object> break_point_object) {
13645 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); 13649 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
13650 Isolate::Current());
13646 if (break_point_info->IsUndefined()) return; 13651 if (break_point_info->IsUndefined()) return;
13647 BreakPointInfo::ClearBreakPoint( 13652 BreakPointInfo::ClearBreakPoint(
13648 Handle<BreakPointInfo>::cast(break_point_info), 13653 Handle<BreakPointInfo>::cast(break_point_info),
13649 break_point_object); 13654 break_point_object);
13650 } 13655 }
13651 13656
13652 13657
13653 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, 13658 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
13654 int code_position, 13659 int code_position,
13655 int source_position, 13660 int source_position,
13656 int statement_position, 13661 int statement_position,
13657 Handle<Object> break_point_object) { 13662 Handle<Object> break_point_object) {
13658 Isolate* isolate = Isolate::Current(); 13663 Isolate* isolate = Isolate::Current();
13659 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position)); 13664 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
13665 isolate);
13660 if (!break_point_info->IsUndefined()) { 13666 if (!break_point_info->IsUndefined()) {
13661 BreakPointInfo::SetBreakPoint( 13667 BreakPointInfo::SetBreakPoint(
13662 Handle<BreakPointInfo>::cast(break_point_info), 13668 Handle<BreakPointInfo>::cast(break_point_info),
13663 break_point_object); 13669 break_point_object);
13664 return; 13670 return;
13665 } 13671 }
13666 13672
13667 // Adding a new break point for a code position which did not have any 13673 // Adding a new break point for a code position which did not have any
13668 // break points before. Try to find a free slot. 13674 // break points before. Try to find a free slot.
13669 int index = kNoBreakPointInfo; 13675 int index = kNoBreakPointInfo;
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
13990 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13996 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13991 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13997 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13992 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13998 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13993 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13999 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13994 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14000 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13995 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14001 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13996 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14002 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13997 } 14003 }
13998 14004
13999 } } // namespace v8::internal 14005 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698