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 "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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return *name; | 73 return *name; |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 RUNTIME_FUNCTION(Runtime_ToMethod) { | 77 RUNTIME_FUNCTION(Runtime_ToMethod) { |
78 HandleScope scope(isolate); | 78 HandleScope scope(isolate); |
79 DCHECK(args.length() == 2); | 79 DCHECK(args.length() == 2); |
80 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 80 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
81 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); | 81 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); |
82 Handle<JSFunction> clone = JSFunction::CloneClosure(fun); | 82 Handle<JSFunction> clone = JSFunction::CloneClosure(fun); |
83 Handle<Symbol> home_object_symbol(isolate->heap()->home_object_symbol()); | 83 Handle<Symbol> home_object_symbol(isolate->factory()->home_object_symbol()); |
84 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol, | 84 JSObject::SetOwnPropertyIgnoreAttributes(clone, home_object_symbol, |
85 home_object, DONT_ENUM).Assert(); | 85 home_object, DONT_ENUM).Assert(); |
86 return *clone; | 86 return *clone; |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { | 90 RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { |
91 DCHECK(args.length() == 0); | 91 DCHECK(args.length() == 0); |
92 return isolate->heap()->home_object_symbol(); | 92 return isolate->heap()->home_object_symbol(); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name, | 96 static MaybeHandle<Object> DefineClass(Isolate* isolate, Handle<Object> name, |
97 Handle<Object> super_class, | 97 Handle<Object> super_class, |
98 Handle<JSFunction> constructor, | 98 Handle<JSFunction> constructor, |
99 int start_position, int end_position) { | 99 int start_position, int end_position) { |
100 Handle<Object> prototype_parent; | 100 Handle<Object> prototype_parent; |
101 Handle<Object> constructor_parent; | 101 Handle<Object> constructor_parent; |
102 | 102 |
103 if (super_class->IsTheHole()) { | 103 if (super_class->IsTheHole()) { |
104 prototype_parent = isolate->initial_object_prototype(); | 104 prototype_parent = isolate->initial_object_prototype(); |
105 } else { | 105 } else { |
106 if (super_class->IsNull()) { | 106 if (super_class->IsNull()) { |
107 prototype_parent = isolate->factory()->null_value(); | 107 prototype_parent = isolate->factory()->null_value(); |
108 } else if (super_class->IsSpecFunction()) { | 108 } else if (super_class->IsJSFunction()) { // TODO(bmeurer): IsConstructor. |
109 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { | 109 if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) { |
110 THROW_NEW_ERROR( | 110 THROW_NEW_ERROR( |
111 isolate, | 111 isolate, |
112 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), | 112 NewTypeError(MessageTemplate::kExtendsValueGenerator, super_class), |
113 Object); | 113 Object); |
114 } | 114 } |
115 ASSIGN_RETURN_ON_EXCEPTION( | 115 ASSIGN_RETURN_ON_EXCEPTION( |
116 isolate, prototype_parent, | 116 isolate, prototype_parent, |
117 Runtime::GetObjectProperty(isolate, super_class, | 117 Runtime::GetObjectProperty(isolate, super_class, |
118 isolate->factory()->prototype_string(), | 118 isolate->factory()->prototype_string(), |
119 SLOPPY), | 119 SLOPPY), |
120 Object); | 120 Object); |
121 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { | 121 if (!prototype_parent->IsNull() && !prototype_parent->IsSpecObject()) { |
122 THROW_NEW_ERROR( | 122 THROW_NEW_ERROR( |
123 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, | 123 isolate, NewTypeError(MessageTemplate::kPrototypeParentNotAnObject, |
124 prototype_parent), | 124 prototype_parent), |
125 Object); | 125 Object); |
126 } | 126 } |
127 constructor_parent = super_class; | 127 constructor_parent = super_class; |
128 } else { | 128 } else { |
129 // TODO(arv): Should be IsConstructor. | |
130 THROW_NEW_ERROR( | 129 THROW_NEW_ERROR( |
131 isolate, | 130 isolate, |
132 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class), | 131 NewTypeError(MessageTemplate::kExtendsValueNotFunction, super_class), |
133 Object); | 132 Object); |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 Handle<Map> map = | 136 Handle<Map> map = |
138 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 137 isolate->factory()->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
139 if (constructor->map()->is_strong()) { | 138 if (constructor->map()->is_strong()) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 Handle<Object> result; | 547 Handle<Object> result; |
549 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 548 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
550 isolate, result, | 549 isolate, result, |
551 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(), | 550 Execution::Call(isolate, reflect, isolate->factory()->undefined_value(), |
552 arraysize(argv), argv)); | 551 arraysize(argv), argv)); |
553 | 552 |
554 return *result; | 553 return *result; |
555 } | 554 } |
556 } // namespace internal | 555 } // namespace internal |
557 } // namespace v8 | 556 } // namespace v8 |
OLD | NEW |