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

Side by Side Diff: src/runtime.cc

Issue 22962009: Add access check for observed objects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged to trunk Created 7 years, 3 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-object-observe.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 14487 matching lines...) Expand 10 before | Expand all | Expand 10 after
14498 14498
14499 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { 14499 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) {
14500 SealHandleScope shs(isolate); 14500 SealHandleScope shs(isolate);
14501 ASSERT(args.length() == 2); 14501 ASSERT(args.length() == 2);
14502 CONVERT_ARG_CHECKED(JSObject, obj1, 0); 14502 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
14503 CONVERT_ARG_CHECKED(JSObject, obj2, 1); 14503 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
14504 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); 14504 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
14505 } 14505 }
14506 14506
14507 14507
14508 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) {
14509 SealHandleScope shs(isolate);
14510 ASSERT(args.length() == 1);
14511 CONVERT_ARG_CHECKED(HeapObject, obj, 0);
14512 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded());
14513 }
14514
14515
14508 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { 14516 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
14509 SealHandleScope shs(isolate); 14517 SealHandleScope shs(isolate);
14510 ASSERT(args.length() == 1); 14518 ASSERT(args.length() == 1);
14511 14519
14512 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); 14520 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value();
14513 JSReceiver* obj = JSReceiver::cast(args[0]); 14521 JSReceiver* obj = JSReceiver::cast(args[0]);
14514 if (obj->IsJSGlobalProxy()) { 14522 if (obj->IsJSGlobalProxy()) {
14515 Object* proto = obj->GetPrototype(); 14523 Object* proto = obj->GetPrototype();
14516 if (proto->IsNull()) return isolate->heap()->false_value(); 14524 if (proto->IsNull()) return isolate->heap()->false_value();
14517 ASSERT(proto->IsJSGlobalObject()); 14525 ASSERT(proto->IsJSGlobalObject());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
14575 ASSERT(args.length() == 1); 14583 ASSERT(args.length() == 1);
14576 Object* object = args[0]; 14584 Object* object = args[0];
14577 if (object->IsJSGlobalProxy()) { 14585 if (object->IsJSGlobalProxy()) {
14578 object = object->GetPrototype(isolate); 14586 object = object->GetPrototype(isolate);
14579 if (object->IsNull()) return isolate->heap()->undefined_value(); 14587 if (object->IsNull()) return isolate->heap()->undefined_value();
14580 } 14588 }
14581 return object; 14589 return object;
14582 } 14590 }
14583 14591
14584 14592
14593 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) {
14594 HandleScope scope(isolate);
14595 ASSERT(args.length() == 3);
14596 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0);
14597 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1);
14598 ASSERT(object->IsAccessCheckNeeded());
14599 Handle<Object> key = args.at<Object>(2);
14600 SaveContext save(isolate);
14601 isolate->set_context(observer->context());
14602 if (!isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(),
14603 v8::ACCESS_KEYS)) {
14604 return isolate->heap()->false_value();
14605 }
14606 bool access_allowed = false;
14607 uint32_t index = 0;
14608 if (key->ToArrayIndex(&index) ||
14609 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) {
14610 access_allowed =
14611 isolate->MayIndexedAccess(*object, index, v8::ACCESS_GET) &&
14612 isolate->MayIndexedAccess(*object, index, v8::ACCESS_HAS);
14613 } else {
14614 access_allowed = isolate->MayNamedAccess(*object, *key, v8::ACCESS_GET) &&
14615 isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS);
14616 }
14617 return isolate->heap()->ToBoolean(access_allowed);
14618 }
14619
14620
14585 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, 14621 static MaybeObject* ArrayConstructorCommon(Isolate* isolate,
14586 Handle<JSFunction> constructor, 14622 Handle<JSFunction> constructor,
14587 Handle<Object> type_info, 14623 Handle<Object> type_info,
14588 Arguments* caller_args) { 14624 Arguments* caller_args) {
14589 bool holey = false; 14625 bool holey = false;
14590 bool can_use_type_feedback = true; 14626 bool can_use_type_feedback = true;
14591 if (caller_args->length() == 1) { 14627 if (caller_args->length() == 1) {
14592 Object* argument_one = (*caller_args)[0]; 14628 Object* argument_one = (*caller_args)[0];
14593 if (argument_one->IsSmi()) { 14629 if (argument_one->IsSmi()) {
14594 int value = Smi::cast(argument_one)->value(); 14630 int value = Smi::cast(argument_one)->value();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
14763 // Handle last resort GC and make sure to allow future allocations 14799 // Handle last resort GC and make sure to allow future allocations
14764 // to grow the heap without causing GCs (if possible). 14800 // to grow the heap without causing GCs (if possible).
14765 isolate->counters()->gc_last_resort_from_js()->Increment(); 14801 isolate->counters()->gc_last_resort_from_js()->Increment();
14766 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14802 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14767 "Runtime::PerformGC"); 14803 "Runtime::PerformGC");
14768 } 14804 }
14769 } 14805 }
14770 14806
14771 14807
14772 } } // namespace v8::internal 14808 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698