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

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

Issue 1402973002: Move some code from Runtime_GetPrototype into a new Object::GetPrototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
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 "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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 return Object::SetProperty(&it, value, language_mode, 151 return Object::SetProperty(&it, value, language_mode,
152 Object::MAY_BE_STORE_FROM_KEYED); 152 Object::MAY_BE_STORE_FROM_KEYED);
153 } 153 }
154 154
155 155
156 RUNTIME_FUNCTION(Runtime_GetPrototype) { 156 RUNTIME_FUNCTION(Runtime_GetPrototype) {
157 HandleScope scope(isolate); 157 HandleScope scope(isolate);
158 DCHECK(args.length() == 1); 158 DCHECK(args.length() == 1);
159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 159 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
160 // We don't expect access checks to be needed on JSProxy objects. 160 return *Object::GetPrototype(isolate, obj);
161 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
162 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER);
163 Handle<Context> context(isolate->context());
164 do {
165 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() &&
166 !isolate->MayAccess(context,
167 PrototypeIterator::GetCurrent<JSObject>(iter))) {
168 return isolate->heap()->null_value();
169 }
170 iter.AdvanceIgnoringProxies();
171 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
172 return *PrototypeIterator::GetCurrent(iter);
173 }
174 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN));
175 return *PrototypeIterator::GetCurrent(iter);
176 } 161 }
177 162
178 163
179 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { 164 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) {
180 HandleScope scope(isolate); 165 HandleScope scope(isolate);
181 DCHECK(args.length() == 2); 166 DCHECK(args.length() == 2);
182 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 167 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
183 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); 168 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
184 DCHECK(!obj->IsAccessCheckNeeded()); 169 DCHECK(!obj->IsAccessCheckNeeded());
185 DCHECK(!obj->map()->is_observed()); 170 DCHECK(!obj->map()->is_observed());
186 Handle<Object> result; 171 Handle<Object> result;
187 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 172 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
188 isolate, result, JSObject::SetPrototype(obj, prototype, false)); 173 isolate, result, JSObject::SetPrototype(obj, prototype, false));
189 return *result; 174 return *result;
190 } 175 }
191 176
192 177
193 RUNTIME_FUNCTION(Runtime_SetPrototype) { 178 RUNTIME_FUNCTION(Runtime_SetPrototype) {
194 HandleScope scope(isolate); 179 HandleScope scope(isolate);
195 DCHECK(args.length() == 2); 180 DCHECK(args.length() == 2);
196 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 181 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
197 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); 182 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
198 if (obj->IsAccessCheckNeeded() && 183 if (obj->IsAccessCheckNeeded() &&
199 !isolate->MayAccess(handle(isolate->context()), obj)) { 184 !isolate->MayAccess(handle(isolate->context()), obj)) {
200 isolate->ReportFailedAccessCheck(obj); 185 isolate->ReportFailedAccessCheck(obj);
201 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 186 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
202 return isolate->heap()->undefined_value(); 187 return isolate->heap()->undefined_value();
203 } 188 }
204 if (obj->map()->is_observed()) { 189 if (obj->map()->is_observed()) {
205 Handle<Object> old_value = 190 Handle<Object> old_value = Object::GetPrototypeWithAccess(isolate, obj);
206 Object::GetPrototypeSkipHiddenPrototypes(isolate, obj);
207 Handle<Object> result; 191 Handle<Object> result;
208 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 192 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
209 isolate, result, JSObject::SetPrototype(obj, prototype, true)); 193 isolate, result, JSObject::SetPrototype(obj, prototype, true));
210 194
211 Handle<Object> new_value = 195 Handle<Object> new_value = Object::GetPrototypeWithAccess(isolate, obj);
212 Object::GetPrototypeSkipHiddenPrototypes(isolate, obj);
213 if (!new_value->SameValue(*old_value)) { 196 if (!new_value->SameValue(*old_value)) {
214 RETURN_FAILURE_ON_EXCEPTION( 197 RETURN_FAILURE_ON_EXCEPTION(
215 isolate, JSObject::EnqueueChangeRecord( 198 isolate, JSObject::EnqueueChangeRecord(
216 obj, "setPrototype", isolate->factory()->proto_string(), 199 obj, "setPrototype", isolate->factory()->proto_string(),
217 old_value)); 200 old_value));
218 } 201 }
219 return *result; 202 return *result;
220 } 203 }
221 Handle<Object> result; 204 Handle<Object> result;
222 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 205 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { 1605 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) {
1623 SealHandleScope shs(isolate); 1606 SealHandleScope shs(isolate);
1624 DCHECK_EQ(1, args.length()); 1607 DCHECK_EQ(1, args.length());
1625 CONVERT_ARG_CHECKED(Object, object, 0); 1608 CONVERT_ARG_CHECKED(Object, object, 0);
1626 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); 1609 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded());
1627 } 1610 }
1628 1611
1629 1612
1630 } // namespace internal 1613 } // namespace internal
1631 } // namespace v8 1614 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698