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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/debug.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 // %ObjectSeal is a fast path and these cases are handled elsewhere. | 441 // %ObjectSeal is a fast path and these cases are handled elsewhere. |
442 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && | 442 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && |
443 !object->map()->is_observed() && !object->IsJSProxy()); | 443 !object->map()->is_observed() && !object->IsJSProxy()); |
444 | 444 |
445 Handle<Object> result; | 445 Handle<Object> result; |
446 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object)); | 446 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Seal(object)); |
447 return *result; | 447 return *result; |
448 } | 448 } |
449 | 449 |
450 | 450 |
451 RUNTIME_FUNCTION(Runtime_LoadGlobalViaContext) { | |
452 HandleScope scope(isolate); | |
453 DCHECK(args.length() == 3); | |
454 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); | |
455 CONVERT_SMI_ARG_CHECKED(index, 1); | |
456 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | |
457 DCHECK(script_context->IsScriptContext()); | |
458 DCHECK(script_context->get(index)->IsPropertyCell()); | |
459 | |
460 Handle<GlobalObject> global(script_context->global_object()); | |
461 | |
462 LookupIterator it(global, name, LookupIterator::OWN); | |
463 | |
464 Handle<Object> result; | |
465 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | |
466 | |
467 if (LookupIterator::DATA == it.state()) { | |
Toon Verwaest
2015/07/10 16:46:11
You should probably do this check before GetProper
Igor Sheludko
2015/07/13 08:34:51
Done.
| |
468 // Now update cell in the script context. | |
469 Handle<PropertyCell> cell = it.GetPropertyCell(); | |
470 script_context->set(index, *cell); | |
471 } else { | |
472 // This is not a fast case, so keep this access in a slow mode. | |
Toon Verwaest
2015/07/10 16:46:11
Add comment that you're doing this just to release
Igor Sheludko
2015/07/13 08:34:51
Done.
| |
473 script_context->set(index, isolate->heap()->empty_property_cell()); | |
474 } | |
475 return *result; | |
476 } | |
477 | |
478 | |
479 RUNTIME_FUNCTION(Runtime_StoreGlobalViaContext) { | |
480 HandleScope scope(isolate); | |
481 DCHECK(args.length() == 5); | |
482 CONVERT_ARG_HANDLE_CHECKED(Context, script_context, 0); | |
483 CONVERT_SMI_ARG_CHECKED(index, 1); | |
484 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2); | |
485 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | |
486 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 4); | |
487 DCHECK(script_context->IsScriptContext()); | |
488 DCHECK(script_context->get(index)->IsPropertyCell()); | |
489 LanguageMode language_mode = language_mode_arg; | |
490 | |
491 Handle<GlobalObject> global(script_context->global_object()); | |
492 | |
493 LookupIterator it(global, name, LookupIterator::OWN); | |
494 | |
495 Handle<Object> result; | |
496 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
497 isolate, result, | |
498 Object::SetProperty(&it, value, language_mode, | |
499 Object::CERTAINLY_NOT_STORE_FROM_KEYED)); | |
500 | |
501 if (LookupIterator::DATA == it.state()) { | |
Toon Verwaest
2015/07/10 16:46:11
Same as above.
Igor Sheludko
2015/07/13 08:34:51
Done.
| |
502 // Now update cell in the script context. | |
503 Handle<PropertyCell> cell = it.GetPropertyCell(); | |
504 script_context->set(index, *cell); | |
505 } else { | |
506 // This is not a fast case, so keep this access in a slow mode. | |
507 script_context->set(index, isolate->heap()->empty_property_cell()); | |
508 } | |
509 return *result; | |
510 } | |
511 | |
512 | |
451 RUNTIME_FUNCTION(Runtime_GetProperty) { | 513 RUNTIME_FUNCTION(Runtime_GetProperty) { |
452 HandleScope scope(isolate); | 514 HandleScope scope(isolate); |
453 DCHECK(args.length() == 2); | 515 DCHECK(args.length() == 2); |
454 | 516 |
455 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 517 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
456 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 518 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
457 | 519 |
458 Handle<Object> result; | 520 Handle<Object> result; |
459 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 521 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
460 isolate, result, | 522 isolate, result, |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1492 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1431 | 1493 |
1432 RETURN_FAILURE_ON_EXCEPTION( | 1494 RETURN_FAILURE_ON_EXCEPTION( |
1433 isolate, | 1495 isolate, |
1434 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1496 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1435 setter, attrs)); | 1497 setter, attrs)); |
1436 return isolate->heap()->undefined_value(); | 1498 return isolate->heap()->undefined_value(); |
1437 } | 1499 } |
1438 } // namespace internal | 1500 } // namespace internal |
1439 } // namespace v8 | 1501 } // namespace v8 |
OLD | NEW |