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

Side by Side Diff: src/runtime.cc

Issue 332863003: Remove AccessControl from AccessorPairs, as it's an invalid usecase of AllCan* (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/cctest/test-api.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 // 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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 DisallowHeapAllocation no_gc; 1892 DisallowHeapAllocation no_gc;
1893 ASSERT(!callback->IsForeign()); 1893 ASSERT(!callback->IsForeign());
1894 if (callback->IsAccessorInfo()) { 1894 if (callback->IsAccessorInfo()) {
1895 AccessorInfo* info = AccessorInfo::cast(callback); 1895 AccessorInfo* info = AccessorInfo::cast(callback);
1896 return 1896 return
1897 (access_type == v8::ACCESS_HAS && 1897 (access_type == v8::ACCESS_HAS &&
1898 (info->all_can_read() || info->all_can_write())) || 1898 (info->all_can_read() || info->all_can_write())) ||
1899 (access_type == v8::ACCESS_GET && info->all_can_read()) || 1899 (access_type == v8::ACCESS_GET && info->all_can_read()) ||
1900 (access_type == v8::ACCESS_SET && info->all_can_write()); 1900 (access_type == v8::ACCESS_SET && info->all_can_write());
1901 } 1901 }
1902 if (callback->IsAccessorPair()) {
1903 AccessorPair* info = AccessorPair::cast(callback);
1904 return
1905 (access_type == v8::ACCESS_HAS &&
1906 (info->all_can_read() || info->all_can_write())) ||
1907 (access_type == v8::ACCESS_GET && info->all_can_read()) ||
1908 (access_type == v8::ACCESS_SET && info->all_can_write());
1909 }
1910 return false; 1902 return false;
1911 } 1903 }
1912 1904
1913 1905
1914 template<class Key> 1906 template<class Key>
1915 static bool CheckGenericAccess( 1907 static bool CheckGenericAccess(
1916 Handle<JSObject> receiver, 1908 Handle<JSObject> receiver,
1917 Handle<Object> end, 1909 Handle<Object> end,
1918 Key key, 1910 Key key,
1919 v8::AccessType access_type, 1911 v8::AccessType access_type,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 1944
1953 Handle<Object> next = lookup.IsProperty() 1945 Handle<Object> next = lookup.IsProperty()
1954 ? handle(lookup.holder()->GetPrototype(), isolate) 1946 ? handle(lookup.holder()->GetPrototype(), isolate)
1955 : Handle<Object>::cast(isolate->factory()->null_value()); 1947 : Handle<Object>::cast(isolate->factory()->null_value());
1956 if (CheckGenericAccess<Handle<Object> >( 1948 if (CheckGenericAccess<Handle<Object> >(
1957 obj, next, name, access_type, &Isolate::MayNamedAccess)) { 1949 obj, next, name, access_type, &Isolate::MayNamedAccess)) {
1958 return; 1950 return;
1959 } 1951 }
1960 1952
1961 // Access check callback denied the access, but some properties 1953 // Access check callback denied the access, but some properties
1962 // can have a special permissions which override callbacks descision 1954 // can have a special permissions which override callbacks decision
1963 // (currently see v8::AccessControl). 1955 // (see v8::AccessControl).
1964 // API callbacks can have per callback access exceptions. 1956 // API callbacks can have per callback access exceptions.
1965 if (lookup.IsFound() && lookup.type() == INTERCEPTOR) { 1957 if (lookup.IsFound() && lookup.type() == INTERCEPTOR) {
1966 lookup.holder()->LookupOwnRealNamedProperty(name, &lookup); 1958 lookup.holder()->LookupOwnRealNamedProperty(name, &lookup);
1967 } 1959 }
1968 1960
1969 if (lookup.IsPropertyCallbacks() && 1961 if (lookup.IsPropertyCallbacks() &&
1970 CheckAccessException(lookup.GetCallbackObject(), access_type)) { 1962 CheckAccessException(lookup.GetCallbackObject(), access_type)) {
1971 return; 1963 return;
1972 } 1964 }
1973 1965
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 Handle<Object> component) { 2160 Handle<Object> component) {
2169 if (component->IsUndefined()) return isolate->factory()->null_value(); 2161 if (component->IsUndefined()) return isolate->factory()->null_value();
2170 Handle<FunctionTemplateInfo> info = 2162 Handle<FunctionTemplateInfo> info =
2171 Handle<FunctionTemplateInfo>::cast(component); 2163 Handle<FunctionTemplateInfo>::cast(component);
2172 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); 2164 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
2173 } 2165 }
2174 2166
2175 2167
2176 RUNTIME_FUNCTION(Runtime_SetAccessorProperty) { 2168 RUNTIME_FUNCTION(Runtime_SetAccessorProperty) {
2177 HandleScope scope(isolate); 2169 HandleScope scope(isolate);
2178 ASSERT(args.length() == 6); 2170 ASSERT(args.length() == 5);
2179 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 2171 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
2180 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 2172 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
2181 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); 2173 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
2182 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); 2174 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
2183 CONVERT_SMI_ARG_CHECKED(attribute, 4); 2175 CONVERT_SMI_ARG_CHECKED(attribute, 4);
2184 CONVERT_SMI_ARG_CHECKED(access_control, 5);
2185 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); 2176 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
2186 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); 2177 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
2187 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( 2178 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
2188 static_cast<PropertyAttributes>(attribute))); 2179 static_cast<PropertyAttributes>(attribute)));
2189 JSObject::DefineAccessor(object, 2180 JSObject::DefineAccessor(object,
2190 name, 2181 name,
2191 InstantiateAccessorComponent(isolate, getter), 2182 InstantiateAccessorComponent(isolate, getter),
2192 InstantiateAccessorComponent(isolate, setter), 2183 InstantiateAccessorComponent(isolate, setter),
2193 static_cast<PropertyAttributes>(attribute), 2184 static_cast<PropertyAttributes>(attribute));
2194 static_cast<v8::AccessControl>(access_control));
2195 return isolate->heap()->undefined_value(); 2185 return isolate->heap()->undefined_value();
2196 } 2186 }
2197 2187
2198 2188
2199 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { 2189 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
2200 HandleScope scope(isolate); 2190 HandleScope scope(isolate);
2201 Handle<Object> args[1] = { name }; 2191 Handle<Object> args[1] = { name };
2202 Handle<Object> error = isolate->factory()->NewTypeError( 2192 Handle<Object> error = isolate->factory()->NewTypeError(
2203 "var_redeclaration", HandleVector(args, 1)); 2193 "var_redeclaration", HandleVector(args, 1));
2204 return isolate->Throw(*error); 2194 return isolate->Throw(*error);
(...skipping 12966 matching lines...) Expand 10 before | Expand all | Expand 10 after
15171 } 15161 }
15172 return NULL; 15162 return NULL;
15173 } 15163 }
15174 15164
15175 15165
15176 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15166 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15177 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15167 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15178 } 15168 }
15179 15169
15180 } } // namespace v8::internal 15170 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698