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

Side by Side Diff: src/runtime/runtime-classes.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 | « src/runtime/runtime.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <stdlib.h>
6 #include <limits>
7
8 #include "src/v8.h"
9
10 #include "src/isolate-inl.h"
11 #include "src/runtime/runtime.h"
12 #include "src/runtime/runtime-utils.h"
13
14
15 namespace v8 {
16 namespace internal {
17
18
19 RUNTIME_FUNCTION(Runtime_ToMethod) {
20 HandleScope scope(isolate);
21 DCHECK(args.length() == 2);
22 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
23 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
24 Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
25 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol());
26 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
27 home_object, DONT_ENUM).Assert();
28 return *clone;
29 }
30
31
32 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
33 DCHECK(args.length() == 0);
34 return isolate->heap()->home_object_symbol();
35 }
36
37
38 RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
39 HandleScope scope(isolate);
40 DCHECK(args.length() == 3);
41 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
42 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
43 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
44
45 if (home_object->IsAccessCheckNeeded() &&
46 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) {
47 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
48 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
49 }
50
51 PrototypeIterator iter(isolate, home_object);
52 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
53 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
54
55 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
56 Handle<Object> result;
57 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
58 return *result;
59 }
60
61
62 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
63 Handle<Object> receiver, Handle<Name> name,
64 Handle<Object> value, StrictMode strict_mode) {
65 if (home_object->IsAccessCheckNeeded() &&
66 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) {
67 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET);
68 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
69 }
70
71 PrototypeIterator iter(isolate, home_object);
72 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
73 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
74
75 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
76 Handle<Object> result;
77 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
78 isolate, result,
79 Object::SetProperty(&it, value, strict_mode,
80 Object::CERTAINLY_NOT_STORE_FROM_KEYED,
81 Object::SUPER_PROPERTY));
82 return *result;
83 }
84
85
86 RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) {
87 HandleScope scope(isolate);
88 DCHECK(args.length() == 4);
89 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
90 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
91 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
92 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
93
94 return StoreToSuper(isolate, home_object, receiver, name, value, STRICT);
95 }
96
97
98 RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) {
99 HandleScope scope(isolate);
100 DCHECK(args.length() == 4);
101 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
102 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
103 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
104 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
105
106 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY);
107 }
108 }
109 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698