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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Check for 'name' properties at parse-time Created 4 years 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 <stdlib.h> 7 #include <stdlib.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "src/accessors.h"
10 #include "src/arguments.h" 11 #include "src/arguments.h"
11 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
12 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
13 #include "src/isolate-inl.h" 14 #include "src/isolate-inl.h"
14 #include "src/messages.h" 15 #include "src/messages.h"
15 #include "src/runtime/runtime.h" 16 #include "src/runtime/runtime.h"
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 20
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0); 182 CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 0);
182 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); 183 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1);
183 CONVERT_SMI_ARG_CHECKED(start_position, 2); 184 CONVERT_SMI_ARG_CHECKED(start_position, 2);
184 CONVERT_SMI_ARG_CHECKED(end_position, 3); 185 CONVERT_SMI_ARG_CHECKED(end_position, 3);
185 186
186 RETURN_RESULT_OR_FAILURE( 187 RETURN_RESULT_OR_FAILURE(
187 isolate, DefineClass(isolate, super_class, constructor, start_position, 188 isolate, DefineClass(isolate, super_class, constructor, start_position,
188 end_position)); 189 end_position));
189 } 190 }
190 191
192
193 RUNTIME_FUNCTION(Runtime_InstallClassNameAccessor) {
194 HandleScope scope(isolate);
195 DCHECK(args.length() == 1);
196 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
197
198 PropertyAttributes attrs =
199 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
200 // Cannot fail since this should only be called when creating an object
201 // literal.
202 CHECK(!JSObject::SetAccessor(
Henrique Ferreiro 2016/11/26 22:42:24 Is this comment and CHECK still valid using SetAcc
Toon Verwaest 2016/11/28 10:40:58 Yes
203 object, Accessors::FunctionNameInfo(object->GetIsolate(), attrs))
204 .is_null());
205 return *object;
206 }
207
191 namespace { 208 namespace {
192 209
193 enum class SuperMode { kLoad, kStore }; 210 enum class SuperMode { kLoad, kStore };
194 211
195 MaybeHandle<JSReceiver> GetSuperHolder( 212 MaybeHandle<JSReceiver> GetSuperHolder(
196 Isolate* isolate, Handle<Object> receiver, Handle<JSObject> home_object, 213 Isolate* isolate, Handle<Object> receiver, Handle<JSObject> home_object,
197 SuperMode mode, MaybeHandle<Name> maybe_name, uint32_t index) { 214 SuperMode mode, MaybeHandle<Name> maybe_name, uint32_t index) {
198 if (home_object->IsAccessCheckNeeded() && 215 if (home_object->IsAccessCheckNeeded() &&
199 !isolate->MayAccess(handle(isolate->context()), home_object)) { 216 !isolate->MayAccess(handle(isolate->context()), home_object)) {
200 isolate->ReportFailedAccessCheck(home_object); 217 isolate->ReportFailedAccessCheck(home_object);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 418
402 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { 419 RUNTIME_FUNCTION(Runtime_GetSuperConstructor) {
403 SealHandleScope shs(isolate); 420 SealHandleScope shs(isolate);
404 DCHECK_EQ(1, args.length()); 421 DCHECK_EQ(1, args.length());
405 CONVERT_ARG_CHECKED(JSFunction, active_function, 0); 422 CONVERT_ARG_CHECKED(JSFunction, active_function, 0);
406 return active_function->map()->prototype(); 423 return active_function->map()->prototype();
407 } 424 }
408 425
409 } // namespace internal 426 } // namespace internal
410 } // namespace v8 427 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698