OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 ASSERT(args.length() == 2); | 2591 ASSERT(args.length() == 2); |
2592 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2592 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
2593 CONVERT_SMI_ARG_CHECKED(properties, 1); | 2593 CONVERT_SMI_ARG_CHECKED(properties, 1); |
2594 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 2594 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
2595 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 2595 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
2596 } | 2596 } |
2597 return *object; | 2597 return *object; |
2598 } | 2598 } |
2599 | 2599 |
2600 | 2600 |
2601 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { | 2601 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpExec) { |
2602 HandleScope scope(isolate); | 2602 HandleScope scope(isolate); |
2603 ASSERT(args.length() == 4); | 2603 ASSERT(args.length() == 4); |
2604 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2604 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2605 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2605 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
2606 // Due to the way the JS calls are constructed this must be less than the | 2606 // Due to the way the JS calls are constructed this must be less than the |
2607 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2607 // length of a string, i.e. it is always a Smi. We check anyway for security. |
2608 CONVERT_SMI_ARG_CHECKED(index, 2); | 2608 CONVERT_SMI_ARG_CHECKED(index, 2); |
2609 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2609 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
2610 RUNTIME_ASSERT(index >= 0); | 2610 RUNTIME_ASSERT(index >= 0); |
2611 RUNTIME_ASSERT(index <= subject->length()); | 2611 RUNTIME_ASSERT(index <= subject->length()); |
2612 isolate->counters()->regexp_entry_runtime()->Increment(); | 2612 isolate->counters()->regexp_entry_runtime()->Increment(); |
2613 Handle<Object> result = RegExpImpl::Exec(regexp, | 2613 Handle<Object> result = RegExpImpl::Exec(regexp, |
2614 subject, | 2614 subject, |
2615 index, | 2615 index, |
2616 last_match_info); | 2616 last_match_info); |
2617 RETURN_IF_EMPTY_HANDLE(isolate, result); | 2617 RETURN_IF_EMPTY_HANDLE(isolate, result); |
2618 return *result; | 2618 return *result; |
2619 } | 2619 } |
2620 | 2620 |
2621 | 2621 |
2622 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { | 2622 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { |
2623 SealHandleScope shs(isolate); | 2623 SealHandleScope shs(isolate); |
2624 ASSERT(args.length() == 3); | 2624 ASSERT(args.length() == 3); |
2625 CONVERT_SMI_ARG_CHECKED(elements_count, 0); | 2625 CONVERT_SMI_ARG_CHECKED(elements_count, 0); |
2626 if (elements_count < 0 || | 2626 if (elements_count < 0 || |
2627 elements_count > FixedArray::kMaxLength || | 2627 elements_count > FixedArray::kMaxLength || |
2628 !Smi::IsValid(elements_count)) { | 2628 !Smi::IsValid(elements_count)) { |
2629 return isolate->ThrowIllegalOperation(); | 2629 return isolate->ThrowIllegalOperation(); |
2630 } | 2630 } |
2631 Object* new_object; | 2631 Object* new_object; |
2632 { MaybeObject* maybe_new_object = | 2632 { MaybeObject* maybe_new_object = |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3274 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, | 3274 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, |
3275 Object* char_code) { | 3275 Object* char_code) { |
3276 if (char_code->IsNumber()) { | 3276 if (char_code->IsNumber()) { |
3277 return isolate->heap()->LookupSingleCharacterStringFromCode( | 3277 return isolate->heap()->LookupSingleCharacterStringFromCode( |
3278 NumberToUint32(char_code) & 0xffff); | 3278 NumberToUint32(char_code) & 0xffff); |
3279 } | 3279 } |
3280 return isolate->heap()->empty_string(); | 3280 return isolate->heap()->empty_string(); |
3281 } | 3281 } |
3282 | 3282 |
3283 | 3283 |
3284 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { | 3284 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCharCodeAt) { |
3285 SealHandleScope shs(isolate); | 3285 SealHandleScope shs(isolate); |
3286 ASSERT(args.length() == 2); | 3286 ASSERT(args.length() == 2); |
3287 | 3287 |
3288 CONVERT_ARG_CHECKED(String, subject, 0); | 3288 CONVERT_ARG_CHECKED(String, subject, 0); |
3289 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 3289 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
3290 | 3290 |
3291 // Flatten the string. If someone wants to get a char at an index | 3291 // Flatten the string. If someone wants to get a char at an index |
3292 // in a cons string, it is likely that more indices will be | 3292 // in a cons string, it is likely that more indices will be |
3293 // accessed. | 3293 // accessed. |
3294 Object* flat; | 3294 Object* flat; |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4544 for (int i = 0; i < end; i++) { | 4544 for (int i = 0; i < end; i++) { |
4545 uint16_t char1 = stream1.GetNext(); | 4545 uint16_t char1 = stream1.GetNext(); |
4546 uint16_t char2 = stream2.GetNext(); | 4546 uint16_t char2 = stream2.GetNext(); |
4547 if (char1 != char2) return Smi::FromInt(char1 - char2); | 4547 if (char1 != char2) return Smi::FromInt(char1 - char2); |
4548 } | 4548 } |
4549 | 4549 |
4550 return Smi::FromInt(str1_length - str2_length); | 4550 return Smi::FromInt(str1_length - str2_length); |
4551 } | 4551 } |
4552 | 4552 |
4553 | 4553 |
4554 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { | 4554 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SubString) { |
4555 HandleScope scope(isolate); | 4555 HandleScope scope(isolate); |
4556 ASSERT(args.length() == 3); | 4556 ASSERT(args.length() == 3); |
4557 | 4557 |
4558 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4558 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
4559 int start, end; | 4559 int start, end; |
4560 // We have a fast integer-only case here to avoid a conversion to double in | 4560 // We have a fast integer-only case here to avoid a conversion to double in |
4561 // the common case where from and to are Smis. | 4561 // the common case where from and to are Smis. |
4562 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 4562 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
4563 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 4563 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
4564 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 4564 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6908 } | 6908 } |
6909 | 6909 |
6910 | 6910 |
6911 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6911 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6912 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6912 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6913 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6913 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6914 return char_length == 0; | 6914 return char_length == 0; |
6915 } | 6915 } |
6916 | 6916 |
6917 | 6917 |
6918 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { | 6918 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { |
6919 SealHandleScope shs(isolate); | 6919 SealHandleScope shs(isolate); |
6920 ASSERT(args.length() == 1); | 6920 ASSERT(args.length() == 1); |
6921 | 6921 |
6922 Object* number = args[0]; | 6922 Object* number = args[0]; |
6923 RUNTIME_ASSERT(number->IsNumber()); | 6923 RUNTIME_ASSERT(number->IsNumber()); |
6924 | 6924 |
6925 return isolate->heap()->NumberToString(number); | 6925 return isolate->heap()->NumberToString(number); |
6926 } | 6926 } |
6927 | 6927 |
6928 | 6928 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7112 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { | 7112 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { |
7113 SealHandleScope shs(isolate); | 7113 SealHandleScope shs(isolate); |
7114 ASSERT(args.length() == 2); | 7114 ASSERT(args.length() == 2); |
7115 | 7115 |
7116 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7116 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7117 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7117 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7118 return isolate->heap()->NumberFromInt32(x * y); | 7118 return isolate->heap()->NumberFromInt32(x * y); |
7119 } | 7119 } |
7120 | 7120 |
7121 | 7121 |
7122 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { | 7122 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { |
7123 HandleScope scope(isolate); | 7123 HandleScope scope(isolate); |
7124 ASSERT(args.length() == 2); | 7124 ASSERT(args.length() == 2); |
7125 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 7125 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
7126 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 7126 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
7127 isolate->counters()->string_add_runtime()->Increment(); | 7127 isolate->counters()->string_add_runtime()->Increment(); |
7128 Handle<String> result = isolate->factory()->NewConsString(str1, str2); | 7128 Handle<String> result = isolate->factory()->NewConsString(str1, str2); |
7129 RETURN_IF_EMPTY_HANDLE(isolate, result); | 7129 RETURN_IF_EMPTY_HANDLE(isolate, result); |
7130 return *result; | 7130 return *result; |
7131 } | 7131 } |
7132 | 7132 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7735 result = equal_prefix_result; | 7735 result = equal_prefix_result; |
7736 } else { | 7736 } else { |
7737 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7737 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
7738 } | 7738 } |
7739 ASSERT(result == | 7739 ASSERT(result == |
7740 StringCharacterStreamCompare(x->GetIsolate()->runtime_state(), x, y)); | 7740 StringCharacterStreamCompare(x->GetIsolate()->runtime_state(), x, y)); |
7741 return result; | 7741 return result; |
7742 } | 7742 } |
7743 | 7743 |
7744 | 7744 |
7745 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { | 7745 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) { |
7746 SealHandleScope shs(isolate); | 7746 SealHandleScope shs(isolate); |
7747 ASSERT(args.length() == 2); | 7747 ASSERT(args.length() == 2); |
7748 | 7748 |
7749 CONVERT_ARG_CHECKED(String, x, 0); | 7749 CONVERT_ARG_CHECKED(String, x, 0); |
7750 CONVERT_ARG_CHECKED(String, y, 1); | 7750 CONVERT_ARG_CHECKED(String, y, 1); |
7751 | 7751 |
7752 isolate->counters()->string_compare_runtime()->Increment(); | 7752 isolate->counters()->string_compare_runtime()->Increment(); |
7753 | 7753 |
7754 // A few fast case tests before we flatten. | 7754 // A few fast case tests before we flatten. |
7755 if (x == y) return Smi::FromInt(EQUAL); | 7755 if (x == y) return Smi::FromInt(EQUAL); |
(...skipping 6821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14577 // This call must not cause lazy deopts, because it's called from deferred | 14577 // This call must not cause lazy deopts, because it's called from deferred |
14578 // code where we can't handle lazy deopts for lack of a suitable bailout | 14578 // code where we can't handle lazy deopts for lack of a suitable bailout |
14579 // ID. So we just try migration and signal failure if necessary, | 14579 // ID. So we just try migration and signal failure if necessary, |
14580 // which will also trigger a deopt. | 14580 // which will also trigger a deopt. |
14581 Handle<Object> result = JSObject::TryMigrateInstance(js_object); | 14581 Handle<Object> result = JSObject::TryMigrateInstance(js_object); |
14582 if (result.is_null()) return Smi::FromInt(0); | 14582 if (result.is_null()) return Smi::FromInt(0); |
14583 return *object; | 14583 return *object; |
14584 } | 14584 } |
14585 | 14585 |
14586 | 14586 |
14587 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { | 14587 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) { |
14588 SealHandleScope shs(isolate); | 14588 SealHandleScope shs(isolate); |
14589 // This is only called from codegen, so checks might be more lax. | 14589 // This is only called from codegen, so checks might be more lax. |
14590 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); | 14590 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); |
14591 Object* key = args[1]; | 14591 Object* key = args[1]; |
14592 | 14592 |
14593 int finger_index = cache->finger_index(); | 14593 int finger_index = cache->finger_index(); |
14594 Object* o = cache->get(finger_index); | 14594 Object* o = cache->get(finger_index); |
14595 if (o == key) { | 14595 if (o == key) { |
14596 // The fastest case: hit the same place again. | 14596 // The fastest case: hit the same place again. |
14597 return cache->get(finger_index + 1); | 14597 return cache->get(finger_index + 1); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14699 | 14699 |
14700 #ifdef DEBUG | 14700 #ifdef DEBUG |
14701 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 14701 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
14702 // Exclude the code in release mode. | 14702 // Exclude the code in release mode. |
14703 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { | 14703 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { |
14704 HandleScope scope(isolate); | 14704 HandleScope scope(isolate); |
14705 ASSERT(args.length() == 0); | 14705 ASSERT(args.length() == 0); |
14706 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 14706 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
14707 int entry_count = 0 | 14707 int entry_count = 0 |
14708 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 14708 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
| 14709 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) |
14709 INLINE_FUNCTION_LIST(COUNT_ENTRY); | 14710 INLINE_FUNCTION_LIST(COUNT_ENTRY); |
14710 #undef COUNT_ENTRY | 14711 #undef COUNT_ENTRY |
14711 Factory* factory = isolate->factory(); | 14712 Factory* factory = isolate->factory(); |
14712 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14713 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
14713 int index = 0; | 14714 int index = 0; |
14714 bool inline_runtime_functions = false; | 14715 bool inline_runtime_functions = false; |
14715 #define ADD_ENTRY(Name, argc, ressize) \ | 14716 #define ADD_ENTRY(Name, argc, ressize) \ |
14716 { \ | 14717 { \ |
14717 HandleScope inner(isolate); \ | 14718 HandleScope inner(isolate); \ |
14718 Handle<String> name; \ | 14719 Handle<String> name; \ |
14719 /* Inline runtime functions have an underscore in front of the name. */ \ | 14720 /* Inline runtime functions have an underscore in front of the name. */ \ |
14720 if (inline_runtime_functions) { \ | 14721 if (inline_runtime_functions) { \ |
14721 name = factory->NewStringFromAscii( \ | 14722 name = factory->NewStringFromAscii( \ |
14722 Vector<const char>("_" #Name, StrLength("_" #Name))); \ | 14723 Vector<const char>("_" #Name, StrLength("_" #Name))); \ |
14723 } else { \ | 14724 } else { \ |
14724 name = factory->NewStringFromAscii( \ | 14725 name = factory->NewStringFromAscii( \ |
14725 Vector<const char>(#Name, StrLength(#Name))); \ | 14726 Vector<const char>(#Name, StrLength(#Name))); \ |
14726 } \ | 14727 } \ |
14727 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ | 14728 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ |
14728 pair_elements->set(0, *name); \ | 14729 pair_elements->set(0, *name); \ |
14729 pair_elements->set(1, Smi::FromInt(argc)); \ | 14730 pair_elements->set(1, Smi::FromInt(argc)); \ |
14730 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ | 14731 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
14731 elements->set(index++, *pair); \ | 14732 elements->set(index++, *pair); \ |
14732 } | 14733 } |
14733 inline_runtime_functions = false; | 14734 inline_runtime_functions = false; |
14734 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 14735 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| 14736 // Calling hidden runtime functions should just throw. |
| 14737 RUNTIME_HIDDEN_FUNCTION_LIST(ADD_ENTRY) |
14735 inline_runtime_functions = true; | 14738 inline_runtime_functions = true; |
14736 INLINE_FUNCTION_LIST(ADD_ENTRY) | 14739 INLINE_FUNCTION_LIST(ADD_ENTRY) |
14737 #undef ADD_ENTRY | 14740 #undef ADD_ENTRY |
14738 ASSERT_EQ(index, entry_count); | 14741 ASSERT_EQ(index, entry_count); |
14739 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 14742 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
14740 return *result; | 14743 return *result; |
14741 } | 14744 } |
14742 #endif | 14745 #endif |
14743 | 14746 |
14744 | 14747 |
14745 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { | 14748 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Log) { |
14746 HandleScope handle_scope(isolate); | 14749 HandleScope handle_scope(isolate); |
14747 ASSERT(args.length() == 2); | 14750 ASSERT(args.length() == 2); |
14748 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); | 14751 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); |
14749 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); | 14752 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); |
14750 | 14753 |
14751 SmartArrayPointer<char> format_chars = format->ToCString(); | 14754 SmartArrayPointer<char> format_chars = format->ToCString(); |
14752 isolate->logger()->LogRuntime( | 14755 isolate->logger()->LogRuntime( |
14753 Vector<const char>(format_chars.get(), format->length()), elms); | 14756 Vector<const char>(format_chars.get(), format->length()), elms); |
14754 return isolate->heap()->undefined_value(); | 14757 return isolate->heap()->undefined_value(); |
14755 } | 14758 } |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15091 | 15094 |
15092 | 15095 |
15093 // ---------------------------------------------------------------------------- | 15096 // ---------------------------------------------------------------------------- |
15094 // Implementation of Runtime | 15097 // Implementation of Runtime |
15095 | 15098 |
15096 #define F(name, number_of_args, result_size) \ | 15099 #define F(name, number_of_args, result_size) \ |
15097 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 15100 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
15098 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15101 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
15099 | 15102 |
15100 | 15103 |
| 15104 #define FH(name, number_of_args, result_size) \ |
| 15105 { Runtime::kHidden##name, Runtime::RUNTIME_HIDDEN, NULL, \ |
| 15106 FUNCTION_ADDR(RuntimeHidden_##name), number_of_args, result_size }, |
| 15107 |
| 15108 |
15101 #define I(name, number_of_args, result_size) \ | 15109 #define I(name, number_of_args, result_size) \ |
15102 { Runtime::kInline##name, Runtime::INLINE, \ | 15110 { Runtime::kInline##name, Runtime::INLINE, \ |
15103 "_" #name, NULL, number_of_args, result_size }, | 15111 "_" #name, NULL, number_of_args, result_size }, |
15104 | 15112 |
| 15113 |
| 15114 #define IO(name, number_of_args, result_size) \ |
| 15115 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \ |
| 15116 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
| 15117 |
| 15118 |
15105 static const Runtime::Function kIntrinsicFunctions[] = { | 15119 static const Runtime::Function kIntrinsicFunctions[] = { |
15106 RUNTIME_FUNCTION_LIST(F) | 15120 RUNTIME_FUNCTION_LIST(F) |
| 15121 RUNTIME_HIDDEN_FUNCTION_LIST(FH) |
15107 INLINE_FUNCTION_LIST(I) | 15122 INLINE_FUNCTION_LIST(I) |
| 15123 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
15108 }; | 15124 }; |
15109 | 15125 |
| 15126 #undef IO |
15110 #undef I | 15127 #undef I |
| 15128 #undef FH |
15111 #undef F | 15129 #undef F |
15112 | 15130 |
15113 | 15131 |
15114 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap, | 15132 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap, |
15115 Object* dictionary) { | 15133 Object* dictionary) { |
15116 ASSERT(dictionary != NULL); | 15134 ASSERT(dictionary != NULL); |
15117 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0); | 15135 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0); |
15118 for (int i = 0; i < kNumFunctions; ++i) { | 15136 for (int i = 0; i < kNumFunctions; ++i) { |
| 15137 const char* name = kIntrinsicFunctions[i].name; |
| 15138 if (name == NULL) continue; |
15119 Object* name_string; | 15139 Object* name_string; |
15120 { MaybeObject* maybe_name_string = | 15140 { MaybeObject* maybe_name_string = |
15121 heap->InternalizeUtf8String(kIntrinsicFunctions[i].name); | 15141 heap->InternalizeUtf8String(name); |
15122 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string; | 15142 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string; |
15123 } | 15143 } |
15124 NameDictionary* name_dictionary = NameDictionary::cast(dictionary); | 15144 NameDictionary* name_dictionary = NameDictionary::cast(dictionary); |
15125 { MaybeObject* maybe_dictionary = name_dictionary->Add( | 15145 { MaybeObject* maybe_dictionary = name_dictionary->Add( |
15126 String::cast(name_string), | 15146 String::cast(name_string), |
15127 Smi::FromInt(i), | 15147 Smi::FromInt(i), |
15128 PropertyDetails(NONE, NORMAL, Representation::None())); | 15148 PropertyDetails(NONE, NORMAL, Representation::None())); |
15129 if (!maybe_dictionary->ToObject(&dictionary)) { | 15149 if (!maybe_dictionary->ToObject(&dictionary)) { |
15130 // Non-recoverable failure. Calling code must restart heap | 15150 // Non-recoverable failure. Calling code must restart heap |
15131 // initialization. | 15151 // initialization. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15169 // Handle last resort GC and make sure to allow future allocations | 15189 // Handle last resort GC and make sure to allow future allocations |
15170 // to grow the heap without causing GCs (if possible). | 15190 // to grow the heap without causing GCs (if possible). |
15171 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15191 isolate->counters()->gc_last_resort_from_js()->Increment(); |
15172 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15192 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
15173 "Runtime::PerformGC"); | 15193 "Runtime::PerformGC"); |
15174 } | 15194 } |
15175 } | 15195 } |
15176 | 15196 |
15177 | 15197 |
15178 } } // namespace v8::internal | 15198 } } // namespace v8::internal |
OLD | NEW |