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

Side by Side Diff: src/runtime/runtime-classes.cc

Issue 638193004: Keyed loads from super with numeric keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor test update Created 6 years, 2 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 | « no previous file | 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return *clone; 50 return *clone;
51 } 51 }
52 52
53 53
54 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { 54 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
55 DCHECK(args.length() == 0); 55 DCHECK(args.length() == 0);
56 return isolate->heap()->home_object_symbol(); 56 return isolate->heap()->home_object_symbol();
57 } 57 }
58 58
59 59
60 static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver,
61 Handle<JSObject> home_object, Handle<Name> name) {
62 if (home_object->IsAccessCheckNeeded() &&
63 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) {
64 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
65 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
66 }
67
68 PrototypeIterator iter(isolate, home_object);
69 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
70 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
71
72 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
73 Handle<Object> result;
74 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
75 return *result;
76 }
77
78
79 RUNTIME_FUNCTION(Runtime_DefineClass) { 60 RUNTIME_FUNCTION(Runtime_DefineClass) {
80 HandleScope scope(isolate); 61 HandleScope scope(isolate);
81 DCHECK(args.length() == 6); 62 DCHECK(args.length() == 6);
82 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); 63 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
83 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 1); 64 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 1);
84 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 2); 65 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 2);
85 CONVERT_ARG_HANDLE_CHECKED(Script, script, 3); 66 CONVERT_ARG_HANDLE_CHECKED(Script, script, 3);
86 CONVERT_SMI_ARG_CHECKED(start_position, 4); 67 CONVERT_SMI_ARG_CHECKED(start_position, 4);
87 CONVERT_SMI_ARG_CHECKED(end_position, 5); 68 CONVERT_SMI_ARG_CHECKED(end_position, 5);
88 69
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return isolate->ThrowIllegalOperation(); 183 return isolate->ThrowIllegalOperation();
203 } 184 }
204 185
205 Handle<String> source(String::cast(Handle<Script>::cast(script)->source())); 186 Handle<String> source(String::cast(Handle<Script>::cast(script)->source()));
206 return *isolate->factory()->NewSubString( 187 return *isolate->factory()->NewSubString(
207 source, Handle<Smi>::cast(start_position)->value(), 188 source, Handle<Smi>::cast(start_position)->value(),
208 Handle<Smi>::cast(end_position)->value()); 189 Handle<Smi>::cast(end_position)->value());
209 } 190 }
210 191
211 192
193 static Object* LoadFromSuper(Isolate* isolate, Handle<Object> receiver,
194 Handle<JSObject> home_object, Handle<Name> name) {
195 if (home_object->IsAccessCheckNeeded() &&
196 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) {
197 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
198 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
199 }
200
201 PrototypeIterator iter(isolate, home_object);
202 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
203 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
204
205 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
206 Handle<Object> result;
207 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
208 return *result;
209 }
210
211
212 static Object* LoadElementFromSuper(Isolate* isolate, Handle<Object> receiver,
213 Handle<JSObject> home_object,
214 uint32_t index) {
215 if (home_object->IsAccessCheckNeeded() &&
216 !isolate->MayIndexedAccess(home_object, index, v8::ACCESS_GET)) {
217 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
218 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
219 }
220
221 PrototypeIterator iter(isolate, home_object);
222 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
223 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
224
225 Handle<Object> result;
226 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
227 isolate, result,
228 Object::GetElementWithReceiver(isolate, proto, receiver, index));
229 return *result;
230 }
231
232
212 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { 233 RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
213 HandleScope scope(isolate); 234 HandleScope scope(isolate);
214 DCHECK(args.length() == 3); 235 DCHECK(args.length() == 3);
215 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); 236 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
216 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 237 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
217 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); 238 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
218 239
219 return LoadFromSuper(isolate, receiver, home_object, name); 240 return LoadFromSuper(isolate, receiver, home_object, name);
220 } 241 }
221 242
222 243
223 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { 244 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) {
224 HandleScope scope(isolate); 245 HandleScope scope(isolate);
225 DCHECK(args.length() == 3); 246 DCHECK(args.length() == 3);
226 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); 247 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
227 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 248 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
228 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); 249 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
229 250
251 uint32_t index;
252 if (key->ToArrayIndex(&index)) {
253 return LoadElementFromSuper(isolate, receiver, home_object, index);
254 }
255
230 Handle<Name> name; 256 Handle<Name> name;
231 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, 257 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
232 Runtime::ToName(isolate, key)); 258 Runtime::ToName(isolate, key));
233 uint32_t index;
234 if (name->AsArrayIndex(&index)) { 259 if (name->AsArrayIndex(&index)) {
235 // TODO(dslomov): Implement. 260 return LoadElementFromSuper(isolate, receiver, home_object, index);
236 return ThrowUnsupportedSuper(isolate);
237 } 261 }
238 return LoadFromSuper(isolate, receiver, home_object, name); 262 return LoadFromSuper(isolate, receiver, home_object, name);
239 } 263 }
240 264
241 265
242 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, 266 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
243 Handle<Object> receiver, Handle<Name> name, 267 Handle<Object> receiver, Handle<Name> name,
244 Handle<Object> value, StrictMode strict_mode) { 268 Handle<Object> value, StrictMode strict_mode) {
245 if (home_object->IsAccessCheckNeeded() && 269 if (home_object->IsAccessCheckNeeded() &&
246 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) { 270 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 DCHECK(args.length() == 4); 343 DCHECK(args.length() == 4);
320 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); 344 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
321 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 345 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
322 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); 346 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
323 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); 347 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
324 348
325 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); 349 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY);
326 } 350 }
327 } 351 }
328 } // namespace v8::internal 352 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698