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 "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 f->shared()->set_name(*name); | 42 f->shared()->set_name(*name); |
43 return isolate->heap()->undefined_value(); | 43 return isolate->heap()->undefined_value(); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { | 47 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { |
48 SealHandleScope shs(isolate); | 48 SealHandleScope shs(isolate); |
49 DCHECK(args.length() == 1); | 49 DCHECK(args.length() == 1); |
50 | 50 |
51 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 51 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
52 RUNTIME_ASSERT(f->RemovePrototype()); | 52 CHECK(f->RemovePrototype()); |
53 f->shared()->set_construct_stub( | 53 f->shared()->set_construct_stub( |
54 *isolate->builtins()->ConstructedNonConstructable()); | 54 *isolate->builtins()->ConstructedNonConstructable()); |
55 | 55 |
56 return isolate->heap()->undefined_value(); | 56 return isolate->heap()->undefined_value(); |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { | 60 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { |
61 HandleScope scope(isolate); | 61 HandleScope scope(isolate); |
62 DCHECK_EQ(1, args.length()); | 62 DCHECK_EQ(1, args.length()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return isolate->heap()->undefined_value(); | 122 return isolate->heap()->undefined_value(); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { | 126 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { |
127 SealHandleScope shs(isolate); | 127 SealHandleScope shs(isolate); |
128 DCHECK(args.length() == 2); | 128 DCHECK(args.length() == 2); |
129 | 129 |
130 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 130 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
131 CONVERT_SMI_ARG_CHECKED(length, 1); | 131 CONVERT_SMI_ARG_CHECKED(length, 1); |
132 RUNTIME_ASSERT((length & 0xC0000000) == 0xC0000000 || | 132 CHECK((length & 0xC0000000) == 0xC0000000 || (length & 0xC0000000) == 0x0); |
133 (length & 0xC0000000) == 0x0); | |
134 fun->shared()->set_length(length); | 133 fun->shared()->set_length(length); |
135 return isolate->heap()->undefined_value(); | 134 return isolate->heap()->undefined_value(); |
136 } | 135 } |
137 | 136 |
138 | 137 |
139 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { | 138 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { |
140 HandleScope scope(isolate); | 139 HandleScope scope(isolate); |
141 DCHECK(args.length() == 2); | 140 DCHECK(args.length() == 2); |
142 | 141 |
143 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 142 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
144 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 143 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
145 RUNTIME_ASSERT(fun->IsConstructor()); | 144 CHECK(fun->IsConstructor()); |
146 RETURN_FAILURE_ON_EXCEPTION(isolate, | 145 RETURN_FAILURE_ON_EXCEPTION(isolate, |
147 Accessors::FunctionSetPrototype(fun, value)); | 146 Accessors::FunctionSetPrototype(fun, value)); |
148 return args[0]; // return TOS | 147 return args[0]; // return TOS |
149 } | 148 } |
150 | 149 |
151 | 150 |
152 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { | 151 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { |
153 SealHandleScope shs(isolate); | 152 SealHandleScope shs(isolate); |
154 DCHECK(args.length() == 1); | 153 DCHECK(args.length() == 1); |
155 | 154 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 222 |
224 return *target; | 223 return *target; |
225 } | 224 } |
226 | 225 |
227 | 226 |
228 // Set the native flag on the function. | 227 // Set the native flag on the function. |
229 // This is used to decide if we should transform null and undefined | 228 // This is used to decide if we should transform null and undefined |
230 // into the global object when doing call and apply. | 229 // into the global object when doing call and apply. |
231 RUNTIME_FUNCTION(Runtime_SetNativeFlag) { | 230 RUNTIME_FUNCTION(Runtime_SetNativeFlag) { |
232 SealHandleScope shs(isolate); | 231 SealHandleScope shs(isolate); |
233 RUNTIME_ASSERT(args.length() == 1); | 232 DCHECK_EQ(1, args.length()); |
234 | 233 |
235 CONVERT_ARG_CHECKED(Object, object, 0); | 234 CONVERT_ARG_CHECKED(Object, object, 0); |
236 | 235 |
237 if (object->IsJSFunction()) { | 236 if (object->IsJSFunction()) { |
238 JSFunction* func = JSFunction::cast(object); | 237 JSFunction* func = JSFunction::cast(object); |
239 func->shared()->set_native(true); | 238 func->shared()->set_native(true); |
240 } | 239 } |
241 return isolate->heap()->undefined_value(); | 240 return isolate->heap()->undefined_value(); |
242 } | 241 } |
243 | 242 |
244 | 243 |
245 RUNTIME_FUNCTION(Runtime_IsConstructor) { | 244 RUNTIME_FUNCTION(Runtime_IsConstructor) { |
246 SealHandleScope shs(isolate); | 245 SealHandleScope shs(isolate); |
247 DCHECK_EQ(1, args.length()); | 246 DCHECK_EQ(1, args.length()); |
248 CONVERT_ARG_CHECKED(Object, object, 0); | 247 CONVERT_ARG_CHECKED(Object, object, 0); |
249 return isolate->heap()->ToBoolean(object->IsConstructor()); | 248 return isolate->heap()->ToBoolean(object->IsConstructor()); |
250 } | 249 } |
251 | 250 |
252 RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) { | 251 RUNTIME_FUNCTION(Runtime_SetForceInlineFlag) { |
253 SealHandleScope shs(isolate); | 252 SealHandleScope shs(isolate); |
254 RUNTIME_ASSERT(args.length() == 1); | 253 DCHECK_EQ(1, args.length()); |
255 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 254 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
256 | 255 |
257 if (object->IsJSFunction()) { | 256 if (object->IsJSFunction()) { |
258 JSFunction* func = JSFunction::cast(*object); | 257 JSFunction* func = JSFunction::cast(*object); |
259 func->shared()->set_force_inline(true); | 258 func->shared()->set_force_inline(true); |
260 } | 259 } |
261 return isolate->heap()->undefined_value(); | 260 return isolate->heap()->undefined_value(); |
262 } | 261 } |
263 | 262 |
264 | 263 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 DCHECK_EQ(1, args.length()); | 298 DCHECK_EQ(1, args.length()); |
300 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 299 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
301 return function->IsJSBoundFunction() | 300 return function->IsJSBoundFunction() |
302 ? *JSBoundFunction::ToString( | 301 ? *JSBoundFunction::ToString( |
303 Handle<JSBoundFunction>::cast(function)) | 302 Handle<JSBoundFunction>::cast(function)) |
304 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 303 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
305 } | 304 } |
306 | 305 |
307 } // namespace internal | 306 } // namespace internal |
308 } // namespace v8 | 307 } // namespace v8 |
OLD | NEW |