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/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/ast/prettyprinter.h" | 8 #include "src/ast/prettyprinter.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
11 #include "src/debug/debug.h" | 11 #include "src/debug/debug.h" |
12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
13 #include "src/isolate-inl.h" | 13 #include "src/isolate-inl.h" |
14 #include "src/messages.h" | 14 #include "src/messages.h" |
15 #include "src/parsing/parser.h" | 15 #include "src/parsing/parser.h" |
16 #include "src/wasm/wasm-module.h" | 16 #include "src/wasm/wasm-module.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { | 21 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { |
22 SealHandleScope shs(isolate); | 22 SealHandleScope shs(isolate); |
23 DCHECK(args.length() == 0); | 23 DCHECK(args.length() == 0); |
24 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 24 CHECK(isolate->bootstrapper()->IsActive()); |
25 return isolate->heap()->undefined_value(); | 25 return isolate->heap()->undefined_value(); |
26 } | 26 } |
27 | 27 |
28 | 28 |
29 RUNTIME_FUNCTION(Runtime_ExportFromRuntime) { | 29 RUNTIME_FUNCTION(Runtime_ExportFromRuntime) { |
30 HandleScope scope(isolate); | 30 HandleScope scope(isolate); |
31 DCHECK(args.length() == 1); | 31 DCHECK(args.length() == 1); |
32 CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0); | 32 CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0); |
33 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 33 CHECK(isolate->bootstrapper()->IsActive()); |
34 JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10, | 34 JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10, |
35 "ExportFromRuntime"); | 35 "ExportFromRuntime"); |
36 Bootstrapper::ExportFromRuntime(isolate, container); | 36 Bootstrapper::ExportFromRuntime(isolate, container); |
37 JSObject::MigrateSlowToFast(container, 0, "ExportFromRuntime"); | 37 JSObject::MigrateSlowToFast(container, 0, "ExportFromRuntime"); |
38 return *container; | 38 return *container; |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 RUNTIME_FUNCTION(Runtime_ExportExperimentalFromRuntime) { | 42 RUNTIME_FUNCTION(Runtime_ExportExperimentalFromRuntime) { |
43 HandleScope scope(isolate); | 43 HandleScope scope(isolate); |
44 DCHECK(args.length() == 1); | 44 DCHECK(args.length() == 1); |
45 CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0); | 45 CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0); |
46 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 46 CHECK(isolate->bootstrapper()->IsActive()); |
47 JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10, | 47 JSObject::NormalizeProperties(container, KEEP_INOBJECT_PROPERTIES, 10, |
48 "ExportExperimentalFromRuntime"); | 48 "ExportExperimentalFromRuntime"); |
49 Bootstrapper::ExportExperimentalFromRuntime(isolate, container); | 49 Bootstrapper::ExportExperimentalFromRuntime(isolate, container); |
50 JSObject::MigrateSlowToFast(container, 0, "ExportExperimentalFromRuntime"); | 50 JSObject::MigrateSlowToFast(container, 0, "ExportExperimentalFromRuntime"); |
51 return *container; | 51 return *container; |
52 } | 52 } |
53 | 53 |
54 | 54 |
55 RUNTIME_FUNCTION(Runtime_InstallToContext) { | 55 RUNTIME_FUNCTION(Runtime_InstallToContext) { |
56 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
57 DCHECK(args.length() == 1); | 57 DCHECK(args.length() == 1); |
58 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 58 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
59 RUNTIME_ASSERT(array->HasFastElements()); | 59 CHECK(array->HasFastElements()); |
60 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 60 CHECK(isolate->bootstrapper()->IsActive()); |
61 Handle<Context> native_context = isolate->native_context(); | 61 Handle<Context> native_context = isolate->native_context(); |
62 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 62 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
63 int length = Smi::cast(array->length())->value(); | 63 int length = Smi::cast(array->length())->value(); |
64 for (int i = 0; i < length; i += 2) { | 64 for (int i = 0; i < length; i += 2) { |
65 RUNTIME_ASSERT(fixed_array->get(i)->IsString()); | 65 CHECK(fixed_array->get(i)->IsString()); |
66 Handle<String> name(String::cast(fixed_array->get(i))); | 66 Handle<String> name(String::cast(fixed_array->get(i))); |
67 RUNTIME_ASSERT(fixed_array->get(i + 1)->IsJSObject()); | 67 CHECK(fixed_array->get(i + 1)->IsJSObject()); |
68 Handle<JSObject> object(JSObject::cast(fixed_array->get(i + 1))); | 68 Handle<JSObject> object(JSObject::cast(fixed_array->get(i + 1))); |
69 int index = Context::ImportedFieldIndexForName(name); | 69 int index = Context::ImportedFieldIndexForName(name); |
70 if (index == Context::kNotFound) { | 70 if (index == Context::kNotFound) { |
71 index = Context::IntrinsicIndexForName(name); | 71 index = Context::IntrinsicIndexForName(name); |
72 } | 72 } |
73 RUNTIME_ASSERT(index != Context::kNotFound); | 73 CHECK(index != Context::kNotFound); |
74 native_context->set(index, *object); | 74 native_context->set(index, *object); |
75 } | 75 } |
76 return isolate->heap()->undefined_value(); | 76 return isolate->heap()->undefined_value(); |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 RUNTIME_FUNCTION(Runtime_Throw) { | 80 RUNTIME_FUNCTION(Runtime_Throw) { |
81 HandleScope scope(isolate); | 81 HandleScope scope(isolate); |
82 DCHECK(args.length() == 1); | 82 DCHECK(args.length() == 1); |
83 return isolate->Throw(args[0]); | 83 return isolate->Throw(args[0]); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 return isolate->heap()->undefined_value(); | 266 return isolate->heap()->undefined_value(); |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { | 270 RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { |
271 DCHECK(args.length() == 1); | 271 DCHECK(args.length() == 1); |
272 HandleScope scope(isolate); | 272 HandleScope scope(isolate); |
273 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); | 273 CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0); |
274 Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 274 Handle<Symbol> key = isolate->factory()->promise_has_handler_symbol(); |
275 // At this point, no revocation has been issued before | 275 // At this point, no revocation has been issued before |
276 RUNTIME_ASSERT( | 276 CHECK(JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)); |
277 JSReceiver::GetDataProperty(promise, key)->IsUndefined(isolate)); | |
278 isolate->ReportPromiseReject(promise, Handle<Object>(), | 277 isolate->ReportPromiseReject(promise, Handle<Object>(), |
279 v8::kPromiseHandlerAddedAfterReject); | 278 v8::kPromiseHandlerAddedAfterReject); |
280 return isolate->heap()->undefined_value(); | 279 return isolate->heap()->undefined_value(); |
281 } | 280 } |
282 | 281 |
283 | 282 |
284 RUNTIME_FUNCTION(Runtime_StackGuard) { | 283 RUNTIME_FUNCTION(Runtime_StackGuard) { |
285 SealHandleScope shs(isolate); | 284 SealHandleScope shs(isolate); |
286 DCHECK(args.length() == 0); | 285 DCHECK(args.length() == 0); |
287 | 286 |
(...skipping 11 matching lines...) Expand all Loading... |
299 SealHandleScope shs(isolate); | 298 SealHandleScope shs(isolate); |
300 DCHECK(args.length() == 0); | 299 DCHECK(args.length() == 0); |
301 return isolate->stack_guard()->HandleInterrupts(); | 300 return isolate->stack_guard()->HandleInterrupts(); |
302 } | 301 } |
303 | 302 |
304 | 303 |
305 RUNTIME_FUNCTION(Runtime_AllocateInNewSpace) { | 304 RUNTIME_FUNCTION(Runtime_AllocateInNewSpace) { |
306 HandleScope scope(isolate); | 305 HandleScope scope(isolate); |
307 DCHECK(args.length() == 1); | 306 DCHECK(args.length() == 1); |
308 CONVERT_SMI_ARG_CHECKED(size, 0); | 307 CONVERT_SMI_ARG_CHECKED(size, 0); |
309 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 308 CHECK(IsAligned(size, kPointerSize)); |
310 RUNTIME_ASSERT(size > 0); | 309 CHECK(size > 0); |
311 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 310 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
312 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); | 311 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); |
313 } | 312 } |
314 | 313 |
315 | 314 |
316 RUNTIME_FUNCTION(Runtime_AllocateInTargetSpace) { | 315 RUNTIME_FUNCTION(Runtime_AllocateInTargetSpace) { |
317 HandleScope scope(isolate); | 316 HandleScope scope(isolate); |
318 DCHECK(args.length() == 2); | 317 DCHECK(args.length() == 2); |
319 CONVERT_SMI_ARG_CHECKED(size, 0); | 318 CONVERT_SMI_ARG_CHECKED(size, 0); |
320 CONVERT_SMI_ARG_CHECKED(flags, 1); | 319 CONVERT_SMI_ARG_CHECKED(flags, 1); |
321 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 320 CHECK(IsAligned(size, kPointerSize)); |
322 RUNTIME_ASSERT(size > 0); | 321 CHECK(size > 0); |
323 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 322 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
324 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 323 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
325 AllocationSpace space = AllocateTargetSpace::decode(flags); | 324 AllocationSpace space = AllocateTargetSpace::decode(flags); |
326 return *isolate->factory()->NewFillerObject(size, double_align, space); | 325 return *isolate->factory()->NewFillerObject(size, double_align, space); |
327 } | 326 } |
328 | 327 |
329 RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) { | 328 RUNTIME_FUNCTION(Runtime_AllocateSeqOneByteString) { |
330 HandleScope scope(isolate); | 329 HandleScope scope(isolate); |
331 DCHECK_EQ(1, args.length()); | 330 DCHECK_EQ(1, args.length()); |
332 CONVERT_SMI_ARG_CHECKED(length, 0); | 331 CONVERT_SMI_ARG_CHECKED(length, 0); |
333 Handle<SeqOneByteString> result; | 332 Handle<SeqOneByteString> result; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 DCHECK(args.length() == 4); | 387 DCHECK(args.length() == 4); |
389 CONVERT_INT32_ARG_CHECKED(template_index, 0); | 388 CONVERT_INT32_ARG_CHECKED(template_index, 0); |
390 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 1); | 389 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 1); |
391 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); | 390 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); |
392 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); | 391 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); |
393 isolate->native_context()->IncrementErrorsThrown(); | 392 isolate->native_context()->IncrementErrorsThrown(); |
394 RETURN_RESULT_OR_FAILURE(isolate, MessageTemplate::FormatMessage( | 393 RETURN_RESULT_OR_FAILURE(isolate, MessageTemplate::FormatMessage( |
395 template_index, arg0, arg1, arg2)); | 394 template_index, arg0, arg1, arg2)); |
396 } | 395 } |
397 | 396 |
398 #define CALLSITE_GET(NAME, RETURN) \ | 397 #define CALLSITE_GET(NAME, RETURN) \ |
399 RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \ | 398 RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \ |
400 HandleScope scope(isolate); \ | 399 HandleScope scope(isolate); \ |
401 DCHECK(args.length() == 1); \ | 400 DCHECK(args.length() == 1); \ |
402 CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \ | 401 CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \ |
403 Handle<String> result; \ | 402 Handle<String> result; \ |
404 CallSite call_site(isolate, call_site_obj); \ | 403 CallSite call_site(isolate, call_site_obj); \ |
405 RUNTIME_ASSERT(call_site.IsJavaScript() || call_site.IsWasm()); \ | 404 CHECK(call_site.IsJavaScript() || call_site.IsWasm()); \ |
406 return RETURN(call_site.NAME(), isolate); \ | 405 return RETURN(call_site.NAME(), isolate); \ |
407 } | 406 } |
408 | 407 |
409 static inline Object* ReturnDereferencedHandle(Handle<Object> obj, | 408 static inline Object* ReturnDereferencedHandle(Handle<Object> obj, |
410 Isolate* isolate) { | 409 Isolate* isolate) { |
411 return *obj; | 410 return *obj; |
412 } | 411 } |
413 | 412 |
414 | 413 |
415 static inline Object* ReturnPositiveNumberOrNull(int value, Isolate* isolate) { | 414 static inline Object* ReturnPositiveNumberOrNull(int value, Isolate* isolate) { |
416 if (value >= 0) return *isolate->factory()->NewNumberFromInt(value); | 415 if (value >= 0) return *isolate->factory()->NewNumberFromInt(value); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 HandleScope scope(isolate); | 619 HandleScope scope(isolate); |
621 DCHECK_EQ(1, args.length()); | 620 DCHECK_EQ(1, args.length()); |
622 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 621 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
623 bool is_wasm_object = object->IsJSObject() && | 622 bool is_wasm_object = object->IsJSObject() && |
624 wasm::IsWasmObject(Handle<JSObject>::cast(object)); | 623 wasm::IsWasmObject(Handle<JSObject>::cast(object)); |
625 return *isolate->factory()->ToBoolean(is_wasm_object); | 624 return *isolate->factory()->ToBoolean(is_wasm_object); |
626 } | 625 } |
627 | 626 |
628 } // namespace internal | 627 } // namespace internal |
629 } // namespace v8 | 628 } // namespace v8 |
OLD | NEW |