Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: src/runtime.cc

Issue 236133005: Handlify Runtime::InitializeIntrinsicFunctionNames. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/runtime.h ('K') | « src/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Handle<NameDictionary> Runtime::InitializeIntrinsicFunctionNames(
15093 Object* dictionary) { 15093 Isolate* isolate, Handle<NameDictionary> dict) {
15094 ASSERT(dictionary != NULL); 15094 ASSERT(dict->NumberOfElements() == 0);
15095 ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0); 15095 ASSERT(dict->Capacity() == kNumFunctions);
15096 for (int i = 0; i < kNumFunctions; ++i) { 15096 for (int i = 0; i < kNumFunctions; ++i) {
15097 HandleScope scope(isolate);
Michael Starzinger 2014/04/14 11:10:50 Do we need this handle scope at all? If yes, then
15097 const char* name = kIntrinsicFunctions[i].name; 15098 const char* name = kIntrinsicFunctions[i].name;
15098 if (name == NULL) continue; 15099 if (name == NULL) continue;
15099 Object* name_string; 15100 Handle<NameDictionary> new_dict = NameDictionary::Add(
15100 { MaybeObject* maybe_name_string = 15101 dict,
15101 heap->InternalizeUtf8String(name); 15102 isolate->factory()->InternalizeUtf8String(name),
15102 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string; 15103 Handle<Smi>(Smi::FromInt(i), isolate),
15103 } 15104 PropertyDetails(NONE, NORMAL, Representation::None()));
15104 NameDictionary* name_dictionary = NameDictionary::cast(dictionary); 15105 // The dictionary does not need to grow.
15105 { MaybeObject* maybe_dictionary = name_dictionary->Add( 15106 ASSERT(new_dict.is_identical_to(dict));
15106 String::cast(name_string), 15107 USE(new_dict);
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 } 15108 }
15116 return dictionary; 15109 return dict;
15117 } 15110 }
15118 15111
15119 15112
15120 const Runtime::Function* Runtime::FunctionForName(Handle<String> name) { 15113 const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
15121 Heap* heap = name->GetHeap(); 15114 Heap* heap = name->GetHeap();
15122 int entry = heap->intrinsic_function_names()->FindEntry(*name); 15115 int entry = heap->intrinsic_function_names()->FindEntry(*name);
15123 if (entry != kNotFound) { 15116 if (entry != kNotFound) {
15124 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); 15117 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
15125 int function_index = Smi::cast(smi_index)->value(); 15118 int function_index = Smi::cast(smi_index)->value();
15126 return &(kIntrinsicFunctions[function_index]); 15119 return &(kIntrinsicFunctions[function_index]);
(...skipping 27 matching lines...) Expand all
15154 } 15147 }
15155 } 15148 }
15156 15149
15157 15150
15158 void Runtime::OutOfMemory() { 15151 void Runtime::OutOfMemory() {
15159 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15152 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15160 UNREACHABLE(); 15153 UNREACHABLE();
15161 } 15154 }
15162 15155
15163 } } // namespace v8::internal 15156 } } // namespace v8::internal
OLDNEW
« src/runtime.h ('K') | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698