| 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 "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 HandleScope scope(isolate); | 341 HandleScope scope(isolate); |
| 342 DCHECK(args.length() == 2); | 342 DCHECK(args.length() == 2); |
| 343 | 343 |
| 344 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 344 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 345 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 345 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 346 | 346 |
| 347 RETURN_RESULT_OR_FAILURE(isolate, | 347 RETURN_RESULT_OR_FAILURE(isolate, |
| 348 Runtime::GetObjectProperty(isolate, object, key)); | 348 Runtime::GetObjectProperty(isolate, object, key)); |
| 349 } | 349 } |
| 350 | 350 |
| 351 namespace { | 351 RUNTIME_FUNCTION(Runtime_GetGlobal) { |
| 352 HandleScope scope(isolate); |
| 353 DCHECK_EQ(3, args.length()); |
| 354 CONVERT_SMI_ARG_CHECKED(slot, 0); |
| 355 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
| 356 CONVERT_SMI_ARG_CHECKED(typeof_mode_value, 2); |
| 357 TypeofMode typeof_mode = static_cast<TypeofMode>(typeof_mode_value); |
| 358 bool should_throw_reference_error = typeof_mode == NOT_INSIDE_TYPEOF; |
| 352 | 359 |
| 353 Object* GetGlobal(Isolate* isolate, int slot, Handle<TypeFeedbackVector> vector, | |
| 354 bool should_throw_reference_error) { | |
| 355 FeedbackVectorSlot vector_slot = vector->ToSlot(slot); | 360 FeedbackVectorSlot vector_slot = vector->ToSlot(slot); |
| 356 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, | 361 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, |
| 357 vector->GetKind(vector_slot)); | 362 vector->GetKind(vector_slot)); |
| 358 Handle<String> name(vector->GetName(vector_slot), isolate); | 363 Handle<String> name(vector->GetName(vector_slot), isolate); |
| 359 DCHECK_NE(*name, *isolate->factory()->empty_string()); | 364 DCHECK_NE(*name, *isolate->factory()->empty_string()); |
| 360 | 365 |
| 361 Handle<JSGlobalObject> global = isolate->global_object(); | 366 Handle<JSGlobalObject> global = isolate->global_object(); |
| 362 | 367 |
| 363 Handle<ScriptContextTable> script_contexts( | 368 Handle<ScriptContextTable> script_contexts( |
| 364 global->native_context()->script_context_table()); | 369 global->native_context()->script_context_table()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 377 } | 382 } |
| 378 | 383 |
| 379 Handle<Object> result; | 384 Handle<Object> result; |
| 380 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 385 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 381 isolate, result, | 386 isolate, result, |
| 382 Runtime::GetObjectProperty(isolate, global, name, | 387 Runtime::GetObjectProperty(isolate, global, name, |
| 383 should_throw_reference_error)); | 388 should_throw_reference_error)); |
| 384 return *result; | 389 return *result; |
| 385 } | 390 } |
| 386 | 391 |
| 387 } // namespace | |
| 388 | |
| 389 RUNTIME_FUNCTION(Runtime_GetGlobalInsideTypeof) { | |
| 390 HandleScope scope(isolate); | |
| 391 DCHECK_EQ(2, args.length()); | |
| 392 CONVERT_SMI_ARG_CHECKED(slot, 0); | |
| 393 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); | |
| 394 return GetGlobal(isolate, slot, vector, false); | |
| 395 } | |
| 396 | |
| 397 RUNTIME_FUNCTION(Runtime_GetGlobalNotInsideTypeof) { | |
| 398 HandleScope scope(isolate); | |
| 399 DCHECK_EQ(2, args.length()); | |
| 400 CONVERT_SMI_ARG_CHECKED(slot, 0); | |
| 401 CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); | |
| 402 return GetGlobal(isolate, slot, vector, true); | |
| 403 } | |
| 404 | |
| 405 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 392 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 406 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 393 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
| 407 HandleScope scope(isolate); | 394 HandleScope scope(isolate); |
| 408 DCHECK(args.length() == 2); | 395 DCHECK(args.length() == 2); |
| 409 | 396 |
| 410 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 397 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
| 411 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 398 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
| 412 | 399 |
| 413 RETURN_RESULT_OR_FAILURE( | 400 RETURN_RESULT_OR_FAILURE( |
| 414 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); | 401 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); |
| 415 } | 402 } |
| 416 | 403 |
| 417 | |
| 418 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { | 404 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { |
| 419 HandleScope scope(isolate); | 405 HandleScope scope(isolate); |
| 420 DCHECK_EQ(4, args.length()); | 406 DCHECK_EQ(4, args.length()); |
| 421 | 407 |
| 422 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 408 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 423 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 409 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 424 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 410 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 425 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 411 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
| 426 | 412 |
| 427 #ifdef DEBUG | 413 #ifdef DEBUG |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 472 } |
| 487 | 473 |
| 488 | 474 |
| 489 RUNTIME_FUNCTION(Runtime_SetProperty) { | 475 RUNTIME_FUNCTION(Runtime_SetProperty) { |
| 490 HandleScope scope(isolate); | 476 HandleScope scope(isolate); |
| 491 DCHECK_EQ(4, args.length()); | 477 DCHECK_EQ(4, args.length()); |
| 492 | 478 |
| 493 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 479 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 494 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 480 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 495 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 481 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 496 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3); | 482 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 3); |
| 497 LanguageMode language_mode = language_mode_arg; | |
| 498 | 483 |
| 499 RETURN_RESULT_OR_FAILURE( | 484 RETURN_RESULT_OR_FAILURE( |
| 500 isolate, | 485 isolate, |
| 501 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); | 486 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); |
| 502 } | 487 } |
| 503 | 488 |
| 504 | 489 |
| 505 namespace { | 490 namespace { |
| 506 | 491 |
| 507 // ES6 section 12.5.4. | 492 // ES6 section 12.5.4. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 isolate, o, key, &success, LookupIterator::OWN); | 966 isolate, o, key, &success, LookupIterator::OWN); |
| 982 if (!success) return isolate->heap()->exception(); | 967 if (!success) return isolate->heap()->exception(); |
| 983 MAYBE_RETURN( | 968 MAYBE_RETURN( |
| 984 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 969 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
| 985 isolate->heap()->exception()); | 970 isolate->heap()->exception()); |
| 986 return *value; | 971 return *value; |
| 987 } | 972 } |
| 988 | 973 |
| 989 } // namespace internal | 974 } // namespace internal |
| 990 } // namespace v8 | 975 } // namespace v8 |
| OLD | NEW |