| OLD | NEW |
| 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 "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 | 180 |
| 181 RUNTIME_FUNCTION(Runtime_DefineClass) { | 181 RUNTIME_FUNCTION(Runtime_DefineClass) { |
| 182 HandleScope scope(isolate); | 182 HandleScope scope(isolate); |
| 183 DCHECK(args.length() == 4); | 183 DCHECK(args.length() == 4); |
| 184 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); | 184 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); |
| 185 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); | 185 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); |
| 186 CONVERT_SMI_ARG_CHECKED(start_position, 2); | 186 CONVERT_SMI_ARG_CHECKED(start_position, 2); |
| 187 CONVERT_SMI_ARG_CHECKED(end_position, 3); | 187 CONVERT_SMI_ARG_CHECKED(end_position, 3); |
| 188 | 188 |
| 189 Handle<Object> result; | 189 RETURN_RESULT_OR_FAILURE( |
| 190 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 190 isolate, DefineClass(isolate, super_class, constructor, start_position, |
| 191 isolate, result, DefineClass(isolate, super_class, constructor, | 191 end_position)); |
| 192 start_position, end_position)); | |
| 193 return *result; | |
| 194 } | 192 } |
| 195 | 193 |
| 196 | 194 |
| 197 static MaybeHandle<Object> LoadFromSuper(Isolate* isolate, | 195 static MaybeHandle<Object> LoadFromSuper(Isolate* isolate, |
| 198 Handle<Object> receiver, | 196 Handle<Object> receiver, |
| 199 Handle<JSObject> home_object, | 197 Handle<JSObject> home_object, |
| 200 Handle<Name> name) { | 198 Handle<Name> name) { |
| 201 if (home_object->IsAccessCheckNeeded() && | 199 if (home_object->IsAccessCheckNeeded() && |
| 202 !isolate->MayAccess(handle(isolate->context()), home_object)) { | 200 !isolate->MayAccess(handle(isolate->context()), home_object)) { |
| 203 isolate->ReportFailedAccessCheck(home_object); | 201 isolate->ReportFailedAccessCheck(home_object); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 238 } |
| 241 | 239 |
| 242 | 240 |
| 243 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { | 241 RUNTIME_FUNCTION(Runtime_LoadFromSuper) { |
| 244 HandleScope scope(isolate); | 242 HandleScope scope(isolate); |
| 245 DCHECK_EQ(3, args.length()); | 243 DCHECK_EQ(3, args.length()); |
| 246 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 244 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
| 247 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 245 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 248 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | 246 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); |
| 249 | 247 |
| 250 Handle<Object> result; | 248 RETURN_RESULT_OR_FAILURE(isolate, |
| 251 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 249 LoadFromSuper(isolate, receiver, home_object, name)); |
| 252 isolate, result, LoadFromSuper(isolate, receiver, home_object, name)); | |
| 253 return *result; | |
| 254 } | 250 } |
| 255 | 251 |
| 256 | 252 |
| 257 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { | 253 RUNTIME_FUNCTION(Runtime_LoadKeyedFromSuper) { |
| 258 HandleScope scope(isolate); | 254 HandleScope scope(isolate); |
| 259 DCHECK_EQ(3, args.length()); | 255 DCHECK_EQ(3, args.length()); |
| 260 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 256 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
| 261 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 257 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
| 262 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 258 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
| 263 | 259 |
| 264 uint32_t index = 0; | 260 uint32_t index = 0; |
| 265 Handle<Object> result; | |
| 266 | 261 |
| 267 if (key->ToArrayIndex(&index)) { | 262 if (key->ToArrayIndex(&index)) { |
| 268 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 263 RETURN_RESULT_OR_FAILURE( |
| 269 isolate, result, | 264 isolate, LoadElementFromSuper(isolate, receiver, home_object, index)); |
| 270 LoadElementFromSuper(isolate, receiver, home_object, index)); | |
| 271 return *result; | |
| 272 } | 265 } |
| 273 | 266 |
| 274 Handle<Name> name; | 267 Handle<Name> name; |
| 275 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 268 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 276 Object::ToName(isolate, key)); | 269 Object::ToName(isolate, key)); |
| 277 // TODO(verwaest): Unify using LookupIterator. | 270 // TODO(verwaest): Unify using LookupIterator. |
| 278 if (name->AsArrayIndex(&index)) { | 271 if (name->AsArrayIndex(&index)) { |
| 279 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 272 RETURN_RESULT_OR_FAILURE( |
| 280 isolate, result, | 273 isolate, LoadElementFromSuper(isolate, receiver, home_object, index)); |
| 281 LoadElementFromSuper(isolate, receiver, home_object, index)); | |
| 282 return *result; | |
| 283 } | 274 } |
| 284 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 275 RETURN_RESULT_OR_FAILURE(isolate, |
| 285 isolate, result, LoadFromSuper(isolate, receiver, home_object, name)); | 276 LoadFromSuper(isolate, receiver, home_object, name)); |
| 286 return *result; | |
| 287 } | 277 } |
| 288 | 278 |
| 289 | 279 |
| 290 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, | 280 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object, |
| 291 Handle<Object> receiver, Handle<Name> name, | 281 Handle<Object> receiver, Handle<Name> name, |
| 292 Handle<Object> value, LanguageMode language_mode) { | 282 Handle<Object> value, LanguageMode language_mode) { |
| 293 if (home_object->IsAccessCheckNeeded() && | 283 if (home_object->IsAccessCheckNeeded() && |
| 294 !isolate->MayAccess(handle(isolate->context()), home_object)) { | 284 !isolate->MayAccess(handle(isolate->context()), home_object)) { |
| 295 isolate->ReportFailedAccessCheck(home_object); | 285 isolate->ReportFailedAccessCheck(home_object); |
| 296 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 286 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 394 |
| 405 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { | 395 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
| 406 SealHandleScope shs(isolate); | 396 SealHandleScope shs(isolate); |
| 407 DCHECK_EQ(1, args.length()); | 397 DCHECK_EQ(1, args.length()); |
| 408 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); | 398 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
| 409 return active_function->map()->prototype(); | 399 return active_function->map()->prototype(); |
| 410 } | 400 } |
| 411 | 401 |
| 412 } // namespace internal | 402 } // namespace internal |
| 413 } // namespace v8 | 403 } // namespace v8 |
| OLD | NEW |