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

Side by Side Diff: src/runtime.cc

Issue 428463005: Restore DefineApiAccessorProperty (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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') | test/mjsunit/runtime-gen/estimatenumberofelements.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after
4920 Runtime::GetObjectProperty(isolate, receiver_obj, key_obj)); 4920 Runtime::GetObjectProperty(isolate, receiver_obj, key_obj));
4921 return *result; 4921 return *result;
4922 } 4922 }
4923 4923
4924 4924
4925 static bool IsValidAccessor(Handle<Object> obj) { 4925 static bool IsValidAccessor(Handle<Object> obj) {
4926 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); 4926 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull();
4927 } 4927 }
4928 4928
4929 4929
4930 // Transform getter or setter into something DefineAccessor can handle.
4931 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
4932 Handle<Object> component) {
4933 if (component->IsUndefined()) return isolate->factory()->null_value();
4934 Handle<FunctionTemplateInfo> info =
4935 Handle<FunctionTemplateInfo>::cast(component);
4936 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
4937 }
4938
4939
4940 RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) {
4941 HandleScope scope(isolate);
4942 ASSERT(args.length() == 5);
4943 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4944 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
4945 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
4946 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
4947 CONVERT_SMI_ARG_CHECKED(attribute, 4);
4948 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
4949 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
4950 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
4951 static_cast<PropertyAttributes>(attribute)));
4952 RETURN_FAILURE_ON_EXCEPTION(
4953 isolate, JSObject::DefineAccessor(
4954 object, name, InstantiateAccessorComponent(isolate, getter),
4955 InstantiateAccessorComponent(isolate, setter),
4956 static_cast<PropertyAttributes>(attribute)));
4957 return isolate->heap()->undefined_value();
4958 }
4959
4960
4930 // Implements part of 8.12.9 DefineOwnProperty. 4961 // Implements part of 8.12.9 DefineOwnProperty.
4931 // There are 3 cases that lead here: 4962 // There are 3 cases that lead here:
4932 // Step 4b - define a new accessor property. 4963 // Step 4b - define a new accessor property.
4933 // Steps 9c & 12 - replace an existing data property with an accessor property. 4964 // Steps 9c & 12 - replace an existing data property with an accessor property.
4934 // Step 12 - update an existing accessor property with an accessor or generic 4965 // Step 12 - update an existing accessor property with an accessor or generic
4935 // descriptor. 4966 // descriptor.
4936 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { 4967 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) {
4937 HandleScope scope(isolate); 4968 HandleScope scope(isolate);
4938 ASSERT(args.length() == 5); 4969 ASSERT(args.length() == 5);
4939 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 4970 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
(...skipping 10113 matching lines...) Expand 10 before | Expand all | Expand 10 after
15053 } 15084 }
15054 return NULL; 15085 return NULL;
15055 } 15086 }
15056 15087
15057 15088
15058 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15089 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15059 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15090 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15060 } 15091 }
15061 15092
15062 } } // namespace v8::internal 15093 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/mjsunit/runtime-gen/estimatenumberofelements.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698