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

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: 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/accessors.h"
11 #include "src/api.h"
12 #include "src/arguments.h"
13 #include "src/bailout-reason.h"
14 #include "src/base/cpu.h"
15 #include "src/base/platform/platform.h"
16 #include "src/bootstrapper.h"
17 #include "src/conversions.h"
18 #include "src/global-handles.h"
19 #include "src/isolate-inl.h"
20 #include "src/prototype.h"
21 #include "src/runtime/runtime.h"
22 #include "src/runtime/runtime-utils.h"
23 #include "src/utils.h"
Yang 2014/10/01 11:40:29 Can we do an audit of those includes? My guess is
24
25
26 namespace v8 {
27 namespace internal {
28
29
30 RUNTIME_FUNCTION(Runtime_ToMethod) {
31 HandleScope scope(isolate);
32 DCHECK(args.length() == 2);
33 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
34 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
35 Handle<JSFunction> clone = JSFunction::CloneClosure(fun);
36 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol());
37 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol,
38 home_object, DONT_ENUM).Assert();
39 return *clone;
40 }
41
42
43 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) {
44 DCHECK(args.length() == 0);
45 return isolate->heap()->home_object_symbol();
46 }
47
48
49 RUNTIME_FUNCTION(Runtime_LoadFromSuper) {
50 HandleScope scope(isolate);
51 DCHECK(args.length() == 3);
52 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
53 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
54 CONVERT_ARG_HANDLE_CHECKED(Name, name, 2);
55
56 if (home_object->IsAccessCheckNeeded() &&
57 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_GET)) {
58 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_GET);
59 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
60 }
61
62 PrototypeIterator iter(isolate, home_object);
63 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
64 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
65
66 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
67 Handle<Object> result;
68 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it));
69 return *result;
70 }
71
72
73 static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
74 Handle<Object> receiver, Handle<Name> name,
75 Handle<Object> value, StrictMode strict_mode) {
76 if (home_object->IsAccessCheckNeeded() &&
77 !isolate->MayNamedAccess(home_object, name, v8::ACCESS_SET)) {
78 isolate->ReportFailedAccessCheck(home_object, v8::ACCESS_SET);
79 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
80 }
81
82 PrototypeIterator iter(isolate, home_object);
83 Handle<Object> proto = PrototypeIterator::GetCurrent(iter);
84 if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
85
86 LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
87 Handle<Object> result;
88 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
89 isolate, result,
90 Object::SetProperty(&it, value, strict_mode,
91 Object::CERTAINLY_NOT_STORE_FROM_KEYED,
92 Object::SUPER_PROPERTY));
93 return *result;
94 }
95
96
97 RUNTIME_FUNCTION(Runtime_StoreToSuper_Strict) {
98 HandleScope scope(isolate);
99 DCHECK(args.length() == 4);
100 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
101 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
102 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
103 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
104
105 return StoreToSuper(isolate, home_object, receiver, name, value, STRICT);
106 }
107
108
109 RUNTIME_FUNCTION(Runtime_StoreToSuper_Sloppy) {
110 HandleScope scope(isolate);
111 DCHECK(args.length() == 4);
112 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
113 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
114 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
115 CONVERT_ARG_HANDLE_CHECKED(Name, name, 3);
116
117 return StoreToSuper(isolate, home_object, receiver, name, value, SLOPPY);
118 }
119 }
120 } // 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