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

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

Issue 1419583007: Eagerly mark class prototypes as prototype. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/arguments.h" 10 #include "src/arguments.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } else { 116 } else {
117 THROW_NEW_ERROR( 117 THROW_NEW_ERROR(
118 isolate, 118 isolate,
119 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class), 119 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class),
120 Object); 120 Object);
121 } 121 }
122 } 122 }
123 123
124 Handle<Map> map = 124 Handle<Map> map =
125 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); 125 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
126 map->set_is_prototype_map(true);
126 if (constructor->map()->is_strong()) { 127 if (constructor->map()->is_strong()) {
127 map->set_is_strong(); 128 map->set_is_strong();
128 if (super_class->IsNull()) { 129 if (super_class->IsNull()) {
129 // Strong class is not permitted to extend null. 130 // Strong class is not permitted to extend null.
130 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kStrongExtendNull), 131 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kStrongExtendNull),
131 Object); 132 Object);
132 } 133 }
133 } 134 }
134 Map::SetPrototype(map, prototype_parent); 135 Map::SetPrototype(map, prototype_parent);
135 map->SetConstructor(*constructor); 136 map->SetConstructor(*constructor);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return isolate->heap()->undefined_value(); 217 return isolate->heap()->undefined_value();
217 } 218 }
218 219
219 220
220 RUNTIME_FUNCTION(Runtime_FinalizeClassDefinition) { 221 RUNTIME_FUNCTION(Runtime_FinalizeClassDefinition) {
221 HandleScope scope(isolate); 222 HandleScope scope(isolate);
222 DCHECK(args.length() == 2); 223 DCHECK(args.length() == 2);
223 CONVERT_ARG_HANDLE_CHECKED(JSObject, constructor, 0); 224 CONVERT_ARG_HANDLE_CHECKED(JSObject, constructor, 0);
224 CONVERT_ARG_HANDLE_CHECKED(JSObject, prototype, 1); 225 CONVERT_ARG_HANDLE_CHECKED(JSObject, prototype, 1);
225 226
226 JSObject::MigrateSlowToFast(prototype, 0, "RuntimeToFastProperties");
227 JSObject::MigrateSlowToFast(constructor, 0, "RuntimeToFastProperties"); 227 JSObject::MigrateSlowToFast(constructor, 0, "RuntimeToFastProperties");
228 228
229 if (constructor->map()->is_strong()) { 229 if (constructor->map()->is_strong()) {
230 DCHECK(prototype->map()->is_strong()); 230 DCHECK(prototype->map()->is_strong());
231 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::Freeze(prototype)); 231 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::Freeze(prototype));
232 Handle<Object> result; 232 Handle<Object> result;
233 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 233 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
234 JSObject::Freeze(constructor)); 234 JSObject::Freeze(constructor));
235 return *result; 235 return *result;
236 } 236 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 513 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
514 isolate, result, 514 isolate, result,
515 Execution::New(isolate, super_constructor, original_constructor, 515 Execution::New(isolate, super_constructor, original_constructor,
516 argument_count, arguments.get())); 516 argument_count, arguments.get()));
517 517
518 return *result; 518 return *result;
519 } 519 }
520 520
521 } // namespace internal 521 } // namespace internal
522 } // namespace v8 522 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698