OLD | NEW |
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 <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/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 : isolate->factory()->empty_string(); | 106 : isolate->factory()->empty_string(); |
107 constructor->shared()->set_name(*name_string); | 107 constructor->shared()->set_name(*name_string); |
108 | 108 |
109 JSFunction::SetPrototype(constructor, prototype); | 109 JSFunction::SetPrototype(constructor, prototype); |
110 PropertyAttributes attribs = | 110 PropertyAttributes attribs = |
111 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 111 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
112 RETURN_FAILURE_ON_EXCEPTION( | 112 RETURN_FAILURE_ON_EXCEPTION( |
113 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 113 isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
114 constructor, isolate->factory()->prototype_string(), | 114 constructor, isolate->factory()->prototype_string(), |
115 prototype, attribs)); | 115 prototype, attribs)); |
| 116 |
| 117 // TODO(arv): Only do this conditionally. |
116 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); | 118 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); |
117 RETURN_FAILURE_ON_EXCEPTION( | 119 RETURN_FAILURE_ON_EXCEPTION( |
118 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 120 isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
119 constructor, home_object_symbol, prototype, DONT_ENUM)); | 121 constructor, home_object_symbol, prototype, DONT_ENUM)); |
120 | 122 |
121 if (!constructor_parent.is_null()) { | 123 if (!constructor_parent.is_null()) { |
122 RETURN_FAILURE_ON_EXCEPTION( | 124 RETURN_FAILURE_ON_EXCEPTION( |
123 isolate, | 125 isolate, |
124 JSObject::SetPrototype(constructor, constructor_parent, false)); | 126 JSObject::SetPrototype(constructor, constructor_parent, false)); |
125 } | 127 } |
(...skipping 20 matching lines...) Expand all Loading... |
146 } | 148 } |
147 | 149 |
148 | 150 |
149 RUNTIME_FUNCTION(Runtime_DefineClassMethod) { | 151 RUNTIME_FUNCTION(Runtime_DefineClassMethod) { |
150 HandleScope scope(isolate); | 152 HandleScope scope(isolate); |
151 DCHECK(args.length() == 3); | 153 DCHECK(args.length() == 3); |
152 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 154 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
153 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 155 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
154 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); | 156 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); |
155 | 157 |
156 RETURN_FAILURE_ON_EXCEPTION( | |
157 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | |
158 function, isolate->factory()->home_object_symbol(), object, | |
159 DONT_ENUM)); | |
160 | |
161 uint32_t index; | 158 uint32_t index; |
162 if (key->ToArrayIndex(&index)) { | 159 if (key->ToArrayIndex(&index)) { |
163 RETURN_FAILURE_ON_EXCEPTION( | 160 RETURN_FAILURE_ON_EXCEPTION( |
164 isolate, JSObject::SetOwnElement(object, index, function, STRICT)); | 161 isolate, JSObject::SetOwnElement(object, index, function, STRICT)); |
165 } | 162 } |
166 | 163 |
167 Handle<Name> name; | 164 Handle<Name> name; |
168 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 165 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
169 Runtime::ToName(isolate, key)); | 166 Runtime::ToName(isolate, key)); |
170 if (name->AsArrayIndex(&index)) { | 167 if (name->AsArrayIndex(&index)) { |
(...skipping 13 matching lines...) Expand all Loading... |
184 DCHECK(args.length() == 3); | 181 DCHECK(args.length() == 3); |
185 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 182 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
186 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 183 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
187 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); | 184 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2); |
188 | 185 |
189 Handle<Name> name; | 186 Handle<Name> name; |
190 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 187 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
191 Runtime::ToName(isolate, key)); | 188 Runtime::ToName(isolate, key)); |
192 RETURN_FAILURE_ON_EXCEPTION( | 189 RETURN_FAILURE_ON_EXCEPTION( |
193 isolate, | 190 isolate, |
194 JSObject::SetOwnPropertyIgnoreAttributes( | |
195 getter, isolate->factory()->home_object_symbol(), object, DONT_ENUM)); | |
196 | |
197 RETURN_FAILURE_ON_EXCEPTION( | |
198 isolate, | |
199 JSObject::DefineAccessor(object, name, getter, | 191 JSObject::DefineAccessor(object, name, getter, |
200 isolate->factory()->null_value(), NONE)); | 192 isolate->factory()->null_value(), NONE)); |
201 return isolate->heap()->undefined_value(); | 193 return isolate->heap()->undefined_value(); |
202 } | 194 } |
203 | 195 |
204 | 196 |
205 RUNTIME_FUNCTION(Runtime_DefineClassSetter) { | 197 RUNTIME_FUNCTION(Runtime_DefineClassSetter) { |
206 HandleScope scope(isolate); | 198 HandleScope scope(isolate); |
207 DCHECK(args.length() == 3); | 199 DCHECK(args.length() == 3); |
208 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 200 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
209 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 201 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
210 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); | 202 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); |
211 | 203 |
212 Handle<Name> name; | 204 Handle<Name> name; |
213 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 205 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
214 Runtime::ToName(isolate, key)); | 206 Runtime::ToName(isolate, key)); |
215 RETURN_FAILURE_ON_EXCEPTION( | 207 RETURN_FAILURE_ON_EXCEPTION( |
216 isolate, | 208 isolate, |
217 JSObject::SetOwnPropertyIgnoreAttributes( | |
218 setter, isolate->factory()->home_object_symbol(), object, DONT_ENUM)); | |
219 RETURN_FAILURE_ON_EXCEPTION( | |
220 isolate, | |
221 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 209 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
222 setter, NONE)); | 210 setter, NONE)); |
223 return isolate->heap()->undefined_value(); | 211 return isolate->heap()->undefined_value(); |
224 } | 212 } |
225 | 213 |
226 | 214 |
227 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) { | 215 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) { |
228 HandleScope shs(isolate); | 216 HandleScope shs(isolate); |
229 DCHECK(args.length() == 1); | 217 DCHECK(args.length() == 1); |
230 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 218 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 DCHECK(args.length() == 4); | 431 DCHECK(args.length() == 4); |
444 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 432 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
445 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 433 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
446 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 434 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
447 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); | 435 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); |
448 | 436 |
449 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); | 437 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); |
450 } | 438 } |
451 } | 439 } |
452 } // namespace v8::internal | 440 } // namespace v8::internal |
OLD | NEW |