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

Side by Side Diff: src/runtime.cc

Issue 655002: Merge revisions 3777-3813 from bleding_edge to partial snapshots ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 CONVERT_CHECKED(String, name, args[1]); 589 CONVERT_CHECKED(String, name, args[1]);
590 590
591 // Use recursive implementation to also traverse hidden prototypes 591 // Use recursive implementation to also traverse hidden prototypes
592 GetOwnPropertyImplementation(obj, name, &result); 592 GetOwnPropertyImplementation(obj, name, &result);
593 593
594 if (!result.IsProperty()) 594 if (!result.IsProperty())
595 return Heap::undefined_value(); 595 return Heap::undefined_value();
596 596
597 if (result.type() == CALLBACKS) { 597 if (result.type() == CALLBACKS) {
598 Object* structure = result.GetCallbackObject(); 598 Object* structure = result.GetCallbackObject();
599 if (structure->IsProxy()) { 599 if (structure->IsProxy() || structure->IsAccessorInfo()) {
600 // Property that is internally implemented as a callback. 600 // Property that is internally implemented as a callback or
601 // an API defined callback.
601 Object* value = obj->GetPropertyWithCallback( 602 Object* value = obj->GetPropertyWithCallback(
602 obj, structure, name, result.holder()); 603 obj, structure, name, result.holder());
603 elms->set(0, Heap::false_value()); 604 elms->set(0, Heap::false_value());
604 elms->set(1, value); 605 elms->set(1, value);
605 elms->set(2, Heap::ToBoolean(!result.IsReadOnly())); 606 elms->set(2, Heap::ToBoolean(!result.IsReadOnly()));
606 } else if (structure->IsFixedArray()) { 607 } else if (structure->IsFixedArray()) {
607 // __defineGetter__/__defineSetter__ callback. 608 // __defineGetter__/__defineSetter__ callback.
608 elms->set(0, Heap::true_value()); 609 elms->set(0, Heap::true_value());
609 elms->set(1, FixedArray::cast(structure)->get(0)); 610 elms->set(1, FixedArray::cast(structure)->get(0));
610 elms->set(2, FixedArray::cast(structure)->get(1)); 611 elms->set(2, FixedArray::cast(structure)->get(1));
611 } else { 612 } else {
612 // TODO(ricow): Handle API callbacks.
613 return Heap::undefined_value(); 613 return Heap::undefined_value();
614 } 614 }
615 } else { 615 } else {
616 elms->set(0, Heap::false_value()); 616 elms->set(0, Heap::false_value());
617 elms->set(1, result.GetLazyValue()); 617 elms->set(1, result.GetLazyValue());
618 elms->set(2, Heap::ToBoolean(!result.IsReadOnly())); 618 elms->set(2, Heap::ToBoolean(!result.IsReadOnly()));
619 } 619 }
620 620
621 elms->set(3, Heap::ToBoolean(!result.IsDontEnum())); 621 elms->set(3, Heap::ToBoolean(!result.IsDontEnum()));
622 elms->set(4, Heap::ToBoolean(!result.IsReadOnly())); 622 elms->set(4, Heap::ToBoolean(!result.IsDontDelete()));
623 return *desc; 623 return *desc;
624 } 624 }
625 625
626 626
627 static Object* Runtime_IsExtensible(Arguments args) { 627 static Object* Runtime_IsExtensible(Arguments args) {
628 ASSERT(args.length() == 1); 628 ASSERT(args.length() == 1);
629 CONVERT_CHECKED(JSObject, obj, args[0]); 629 CONVERT_CHECKED(JSObject, obj, args[0]);
630 return obj->map()->is_extensible() ? Heap::true_value() 630 return obj->map()->is_extensible() ? Heap::true_value()
631 : Heap::false_value(); 631 : Heap::false_value();
632 } 632 }
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2881 Handle<Object> result = GetCharAt(str, index); 2881 Handle<Object> result = GetCharAt(str, index);
2882 return *result; 2882 return *result;
2883 } 2883 }
2884 2884
2885 // Fall back to GetObjectProperty. 2885 // Fall back to GetObjectProperty.
2886 return Runtime::GetObjectProperty(args.at<Object>(0), 2886 return Runtime::GetObjectProperty(args.at<Object>(0),
2887 args.at<Object>(1)); 2887 args.at<Object>(1));
2888 } 2888 }
2889 2889
2890 2890
2891 static Object* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
2892 ASSERT(args.length() == 5);
2893 HandleScope scope;
2894 CONVERT_ARG_CHECKED(JSObject, obj, 0);
2895 CONVERT_CHECKED(String, name, args[1]);
2896 CONVERT_CHECKED(Smi, flag_setter, args[2]);
2897 CONVERT_CHECKED(JSFunction, fun, args[3]);
2898 CONVERT_CHECKED(Smi, flag_attr, args[4]);
2899 int unchecked = flag_attr->value();
2900 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
2901 RUNTIME_ASSERT(!obj->IsNull());
2902 LookupResult result;
2903 obj->LocalLookupRealNamedProperty(name, &result);
2904
2905 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
2906 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION
2907 // delete it to avoid running into trouble in DefineAccessor, which
2908 // handles this incorrectly if the property is readonly (does nothing)
2909 if (result.IsValid() &&
2910 (result.type() == FIELD || result.type() == NORMAL
2911 || result.type() == CONSTANT_FUNCTION)) {
2912 obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
2913 }
2914 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr);
2915 }
2916
2917 static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
2918 ASSERT(args.length() == 4);
2919 HandleScope scope;
2920 CONVERT_ARG_CHECKED(JSObject, js_object, 0);
2921 CONVERT_ARG_CHECKED(String, name, 1);
2922 Handle<Object> obj_value = args.at<Object>(2);
2923
2924 CONVERT_CHECKED(Smi, flag, args[3]);
2925 int unchecked = flag->value();
2926 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
2927
2928 LookupResult result;
2929 js_object->LocalLookupRealNamedProperty(*name, &result);
2930
2931 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
2932
2933 // Take special care when attributes are different and there is already
2934 // a property. For simplicity we normalize the property which enables us
2935 // to not worry about changing the instance_descriptor and creating a new
2936 // map. The current version of SetObjectProperty does not handle attributes
2937 // correctly in the case where a property is a field and is reset with
2938 // new attributes.
2939 if (result.IsProperty() && attr != result.GetAttributes()) {
2940 PropertyDetails details = PropertyDetails(attr, NORMAL);
2941 // New attributes - normalize to avoid writing to instance descriptor
2942 js_object->NormalizeProperties(KEEP_INOBJECT_PROPERTIES, 0);
2943 return js_object->SetNormalizedProperty(*name, *obj_value, details);
2944 }
2945
2946 return Runtime::SetObjectProperty(js_object, name, obj_value, attr);
2947 }
2948
2949
2891 Object* Runtime::SetObjectProperty(Handle<Object> object, 2950 Object* Runtime::SetObjectProperty(Handle<Object> object,
2892 Handle<Object> key, 2951 Handle<Object> key,
2893 Handle<Object> value, 2952 Handle<Object> value,
2894 PropertyAttributes attr) { 2953 PropertyAttributes attr) {
2895 HandleScope scope; 2954 HandleScope scope;
2896 2955
2897 if (object->IsUndefined() || object->IsNull()) { 2956 if (object->IsUndefined() || object->IsNull()) {
2898 Handle<Object> args[2] = { key, object }; 2957 Handle<Object> args[2] = { key, object };
2899 Handle<Object> error = 2958 Handle<Object> error =
2900 Factory::NewTypeError("non_object_property_store", 2959 Factory::NewTypeError("non_object_property_store",
(...skipping 5281 matching lines...) Expand 10 before | Expand all | Expand 10 after
8182 } else { 8241 } else {
8183 // Handle last resort GC and make sure to allow future allocations 8242 // Handle last resort GC and make sure to allow future allocations
8184 // to grow the heap without causing GCs (if possible). 8243 // to grow the heap without causing GCs (if possible).
8185 Counters::gc_last_resort_from_js.Increment(); 8244 Counters::gc_last_resort_from_js.Increment();
8186 Heap::CollectAllGarbage(false); 8245 Heap::CollectAllGarbage(false);
8187 } 8246 }
8188 } 8247 }
8189 8248
8190 8249
8191 } } // namespace v8::internal 8250 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698