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

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

Issue 621833002: Extract runtime functions for classes into a separate file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Includes cleaned up Created 6 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 | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/runtime/runtime-classes.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 // 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 HandleScope scope(isolate); 263 HandleScope scope(isolate);
264 DCHECK(args.length() == 1); 264 DCHECK(args.length() == 1);
265 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 265 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
266 Handle<Object> result; 266 Handle<Object> result;
267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 267 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
268 JSObject::PreventExtensions(obj)); 268 JSObject::PreventExtensions(obj));
269 return *result; 269 return *result;
270 } 270 }
271 271
272 272
273 RUNTIME_FUNCTION(Runtime_ToMethod) {
274 HandleScope scope(isolate);
275 DCHECK(args.length() == 2);
276 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
277 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
278 Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
279 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol());
280 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
281 home_object, DONT_ENUM).Assert();
282 return *clone;
283 }
284
285
286 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
287 DCHECK(args.length() == 0);
288 return isolate->heap()->home_object_symbol();
289 }
290
291
292 RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
293 HandleScope scope(isolate);
294 DCHECK(args.length() == 3);
295 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
296 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
297 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
298
299 if (home_object->IsAccessCheckNeeded() &&
300 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) {
301 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
302 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
303 }
304
305 PrototypeIterator iter(isolate, home_object);
306 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
307 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
308
309 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
310 Handle<Object> result;
311 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
312 return *result;
313 }
314
315
316 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
317 Handle<Object> receiver, Handle<Name> name,
318 Handle<Object> value, StrictMode strict_mode) {
319 if (home_object->IsAccessCheckNeeded() &&
320 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) {
321 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET);
322 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
323 }
324
325 PrototypeIterator iter(isolate, home_object);
326 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
327 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
328
329 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
330 Handle<Object> result;
331 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
332 isolate, result,
333 Object::SetProperty(&it, value, strict_mode,
334 Object::CERTAINLY_NOT_STORE_FROM_KEYED,
335 Object::SUPER_PROPERTY));
336 return *result;
337 }
338
339
340 RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) {
341 HandleScope scope(isolate);
342 DCHECK(args.length() == 4);
343 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
344 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
345 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
346 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
347
348 return StoreToSuper(isolate, home_object, receiver, name, value, STRICT);
349 }
350
351
352 RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) {
353 HandleScope scope(isolate);
354 DCHECK(args.length() == 4);
355 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
356 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
357 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
358 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
359
360 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY);
361 }
362
363
364 RUNTIME_FUNCTION(Runtime_IsExtensible) { 273 RUNTIME_FUNCTION(Runtime_IsExtensible) {
365 SealHandleScope shs(isolate); 274 SealHandleScope shs(isolate);
366 DCHECK(args.length() == 1); 275 DCHECK(args.length() == 1);
367 CONVERT_ARG_CHECKED(JSObject, obj, 0); 276 CONVERT_ARG_CHECKED(JSObject, obj, 0);
368 if (obj->IsJSGlobalProxy()) { 277 if (obj->IsJSGlobalProxy()) {
369 PrototypeIterator iter(isolate, obj); 278 PrototypeIterator iter(isolate, obj);
370 if (iter.IsAtEnd()) return isolate->heap()->false_value(); 279 if (iter.IsAtEnd()) return isolate->heap()->false_value();
371 DCHECK(iter.GetCurrent()->IsJSGlobalObject()); 280 DCHECK(iter.GetCurrent()->IsJSGlobalObject());
372 obj = JSObject::cast(iter.GetCurrent()); 281 obj = JSObject::cast(iter.GetCurrent());
373 } 282 }
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 } 3343 }
3435 return NULL; 3344 return NULL;
3436 } 3345 }
3437 3346
3438 3347
3439 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 3348 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
3440 return &(kIntrinsicFunctions[static_cast<int>(id)]); 3349 return &(kIntrinsicFunctions[static_cast<int>(id)]);
3441 } 3350 }
3442 } 3351 }
3443 } // namespace v8::internal 3352 } // namespace v8::internal
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698