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 15071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15082 INLINE_FUNCTION_LIST(I) | 15082 INLINE_FUNCTION_LIST(I) |
15083 INLINE_OPTIMIZED_FUNCTION_LIST(IO) | 15083 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
15084 }; | 15084 }; |
15085 | 15085 |
15086 #undef IO | 15086 #undef IO |
15087 #undef I | 15087 #undef I |
15088 #undef FH | 15088 #undef FH |
15089 #undef F | 15089 #undef F |
15090 | 15090 |
15091 | 15091 |
15092 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap, | 15092 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, |
15093 Object* dictionary) { | 15093 Handle<NameDictionary> dict) { |
15094 ASSERT(dictionary != NULL); | 15094 ASSERT(dict->NumberOfElements() == 0); |
15095 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0); | 15095 HandleScope scope(isolate); |
15096 for (int i = 0; i < kNumFunctions; ++i) { | 15096 for (int i = 0; i < kNumFunctions; ++i) { |
15097 const char* name = kIntrinsicFunctions[i].name; | 15097 const char* name = kIntrinsicFunctions[i].name; |
15098 if (name == NULL) continue; | 15098 if (name == NULL) continue; |
15099 Object* name_string; | 15099 Handle<NameDictionary> new_dict = NameDictionary::AddNameEntry( |
15100 { MaybeObject* maybe_name_string = | 15100 dict, |
15101 heap->InternalizeUtf8String(name); | 15101 isolate->factory()->InternalizeUtf8String(name), |
15102 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string; | 15102 Handle<Smi>(Smi::FromInt(i), isolate), |
15103 } | 15103 PropertyDetails(NONE, NORMAL, Representation::None())); |
15104 NameDictionary* name_dictionary = NameDictionary::cast(dictionary); | 15104 // The dictionary does not need to grow. |
15105 { MaybeObject* maybe_dictionary = name_dictionary->Add( | 15105 CHECK(new_dict.is_identical_to(dict)); |
15106 String::cast(name_string), | |
15107 Smi::FromInt(i), | |
15108 PropertyDetails(NONE, NORMAL, Representation::None())); | |
15109 if (!maybe_dictionary->ToObject(&dictionary)) { | |
15110 // Non-recoverable failure. Calling code must restart heap | |
15111 // initialization. | |
15112 return maybe_dictionary; | |
15113 } | |
15114 } | |
15115 } | 15106 } |
15116 return dictionary; | |
15117 } | 15107 } |
15118 | 15108 |
15119 | 15109 |
15120 const Runtime::Function* Runtime::FunctionForName(Handle<String> name) { | 15110 const Runtime::Function* Runtime::FunctionForName(Handle<String> name) { |
15121 Heap* heap = name->GetHeap(); | 15111 Heap* heap = name->GetHeap(); |
15122 int entry = heap->intrinsic_function_names()->FindEntry(*name); | 15112 int entry = heap->intrinsic_function_names()->FindEntry(*name); |
15123 if (entry != kNotFound) { | 15113 if (entry != kNotFound) { |
15124 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); | 15114 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); |
15125 int function_index = Smi::cast(smi_index)->value(); | 15115 int function_index = Smi::cast(smi_index)->value(); |
15126 return &(kIntrinsicFunctions[function_index]); | 15116 return &(kIntrinsicFunctions[function_index]); |
(...skipping 27 matching lines...) Expand all Loading... |
15154 } | 15144 } |
15155 } | 15145 } |
15156 | 15146 |
15157 | 15147 |
15158 void Runtime::OutOfMemory() { | 15148 void Runtime::OutOfMemory() { |
15159 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15149 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15160 UNREACHABLE(); | 15150 UNREACHABLE(); |
15161 } | 15151 } |
15162 | 15152 |
15163 } } // namespace v8::internal | 15153 } } // namespace v8::internal |
OLD | NEW |