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

Unified Diff: src/runtime/runtime-classes.cc

Issue 1316333002: [strong] weak classes can't inherit from strong ones (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor comment reorder Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/strong/class-object-frozen.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-classes.cc
diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc
index bc273eec307279c02024b674b0ac1843e8d72a73..d1c8568e58250b356bc2e2c3fece76595b383719 100644
--- a/src/runtime/runtime-classes.cc
+++ b/src/runtime/runtime-classes.cc
@@ -138,6 +138,18 @@ static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name,
isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
if (constructor->map()->is_strong()) {
map->set_is_strong();
+ if (super_class->IsNull()) {
+ // Strong class is not permitted to extend null.
+ THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kStrongExtendNull),
+ Object);
+ }
+ } else {
+ if (Handle<HeapObject>::cast(super_class)->map()->is_strong()) {
+ // Weak class is not permitted to extend strong class.
+ THROW_NEW_ERROR(isolate,
+ NewTypeError(MessageTemplate::kStrongWeakExtend, name),
+ Object);
+ }
}
Map::SetPrototype(map, prototype_parent);
map->SetConstructor(*constructor);
@@ -212,28 +224,6 @@ RUNTIME_FUNCTION(Runtime_DefineClass) {
}
-RUNTIME_FUNCTION(Runtime_DefineClassStrong) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 5);
- CONVERT_ARG_HANDLE_CHECKED(Object, name, 0);
- CONVERT_ARG_HANDLE_CHECKED(Object, super_class, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 2);
- CONVERT_SMI_ARG_CHECKED(start_position, 3);
- CONVERT_SMI_ARG_CHECKED(end_position, 4);
-
- if (super_class->IsNull()) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewTypeError(MessageTemplate::kStrongExtendNull));
- }
-
- Handle<Object> result;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, result, DefineClass(isolate, name, super_class, constructor,
- start_position, end_position));
- return *result;
-}
-
-
RUNTIME_FUNCTION(Runtime_DefineClassMethod) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/strong/class-object-frozen.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698