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

Side by Side Diff: src/factory.cc

Issue 227533002: Handlify six allocator functions from the Heap. (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
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "factory.h" 5 #include "factory.h"
6 6
7 #include "isolate-inl.h" 7 #include "isolate-inl.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ASSERT(deopt_entry_count > 0); 161 ASSERT(deopt_entry_count > 0);
162 CALL_HEAP_FUNCTION(isolate(), 162 CALL_HEAP_FUNCTION(isolate(),
163 DeoptimizationOutputData::Allocate(isolate(), 163 DeoptimizationOutputData::Allocate(isolate(),
164 deopt_entry_count, 164 deopt_entry_count,
165 pretenure), 165 pretenure),
166 DeoptimizationOutputData); 166 DeoptimizationOutputData);
167 } 167 }
168 168
169 169
170 Handle<AccessorPair> Factory::NewAccessorPair() { 170 Handle<AccessorPair> Factory::NewAccessorPair() {
171 CALL_HEAP_FUNCTION(isolate(), 171 Handle<AccessorPair> accessors =
172 isolate()->heap()->AllocateAccessorPair(), 172 Handle<AccessorPair>::cast(NewStruct(ACCESSOR_PAIR_TYPE));
173 AccessorPair); 173 accessors->set_getter(*the_hole_value(), SKIP_WRITE_BARRIER);
174 accessors->set_setter(*the_hole_value(), SKIP_WRITE_BARRIER);
175 accessors->set_access_flags(Smi::FromInt(0), SKIP_WRITE_BARRIER);
176 return accessors;
174 } 177 }
175 178
176 179
177 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { 180 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() {
178 CALL_HEAP_FUNCTION(isolate(), 181 Handle<TypeFeedbackInfo> info =
179 isolate()->heap()->AllocateTypeFeedbackInfo(), 182 Handle<TypeFeedbackInfo>::cast(NewStruct(TYPE_FEEDBACK_INFO_TYPE));
180 TypeFeedbackInfo); 183 info->initialize_storage();
184 info->set_feedback_vector(*empty_fixed_array(), SKIP_WRITE_BARRIER);
185 return info;
181 } 186 }
182 187
183 188
184 // Internalized strings are created in the old generation (data space). 189 // Internalized strings are created in the old generation (data space).
185 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { 190 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
186 Utf8StringKey key(string, isolate()->heap()->HashSeed()); 191 Utf8StringKey key(string, isolate()->heap()->HashSeed());
187 return InternalizeStringWithKey(&key); 192 return InternalizeStringWithKey(&key);
188 } 193 }
189 194
190 195
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 551
547 Handle<Symbol> Factory::NewPrivateSymbol() { 552 Handle<Symbol> Factory::NewPrivateSymbol() {
548 CALL_HEAP_FUNCTION( 553 CALL_HEAP_FUNCTION(
549 isolate(), 554 isolate(),
550 isolate()->heap()->AllocatePrivateSymbol(), 555 isolate()->heap()->AllocatePrivateSymbol(),
551 Symbol); 556 Symbol);
552 } 557 }
553 558
554 559
555 Handle<Context> Factory::NewNativeContext() { 560 Handle<Context> Factory::NewNativeContext() {
556 CALL_HEAP_FUNCTION( 561 Handle<FixedArray> array = NewFixedArray(Context::NATIVE_CONTEXT_SLOTS);
557 isolate(), 562 array->set_map_no_write_barrier(*native_context_map());
558 isolate()->heap()->AllocateNativeContext(), 563 Handle<Context> context = Handle<Context>::cast(array);
559 Context); 564 context->set_js_array_maps(*undefined_value());
565 ASSERT(context->IsNativeContext());
566 return context;
560 } 567 }
561 568
562 569
563 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function, 570 Handle<Context> Factory::NewGlobalContext(Handle<JSFunction> function,
564 Handle<ScopeInfo> scope_info) { 571 Handle<ScopeInfo> scope_info) {
565 CALL_HEAP_FUNCTION( 572 CALL_HEAP_FUNCTION(
566 isolate(), 573 isolate(),
567 isolate()->heap()->AllocateGlobalContext(*function, *scope_info), 574 isolate()->heap()->AllocateGlobalContext(*function, *scope_info),
568 Context); 575 Context);
569 } 576 }
570 577
571 578
572 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { 579 Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
573 CALL_HEAP_FUNCTION( 580 Handle<FixedArray> array =
574 isolate(), 581 NewFixedArray(scope_info->ContextLength(), TENURED);
575 isolate()->heap()->AllocateModuleContext(*scope_info), 582 array->set_map_no_write_barrier(*module_context_map());
576 Context); 583 // Instance link will be set later.
584 Handle<Context> context = Handle<Context>::cast(array);
585 context->set_extension(Smi::FromInt(0));
586 return context;
577 } 587 }
578 588
579 589
580 Handle<Context> Factory::NewFunctionContext(int length, 590 Handle<Context> Factory::NewFunctionContext(int length,
581 Handle<JSFunction> function) { 591 Handle<JSFunction> function) {
582 CALL_HEAP_FUNCTION( 592 CALL_HEAP_FUNCTION(
583 isolate(), 593 isolate(),
584 isolate()->heap()->AllocateFunctionContext(length, *function), 594 isolate()->heap()->AllocateFunctionContext(length, *function),
585 Context); 595 Context);
586 } 596 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, SLOPPY); 1207 Handle<JSFunction> function = NewFunctionWithoutPrototype(name, SLOPPY);
1198 function->shared()->set_code(*code); 1208 function->shared()->set_code(*code);
1199 function->set_code(*code); 1209 function->set_code(*code);
1200 ASSERT(!function->has_initial_map()); 1210 ASSERT(!function->has_initial_map());
1201 ASSERT(!function->has_prototype()); 1211 ASSERT(!function->has_prototype());
1202 return function; 1212 return function;
1203 } 1213 }
1204 1214
1205 1215
1206 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { 1216 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
1207 CALL_HEAP_FUNCTION( 1217 Handle<FixedArray> array = NewFixedArray(length, TENURED);
1208 isolate(), 1218 array->set_map_no_write_barrier(*scope_info_map());
1209 isolate()->heap()->AllocateScopeInfo(length), 1219 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array);
1210 ScopeInfo); 1220 return scope_info;
1211 } 1221 }
1212 1222
1213 1223
1214 Handle<JSObject> Factory::NewExternal(void* value) { 1224 Handle<JSObject> Factory::NewExternal(void* value) {
1215 CALL_HEAP_FUNCTION(isolate(), 1225 Handle<Foreign> foreign = NewForeign(static_cast<Address>(value));
1216 isolate()->heap()->AllocateExternal(value), 1226 Handle<JSObject> external = NewJSObjectFromMap(external_map());
1217 JSObject); 1227 external->SetInternalField(0, *foreign);
1228 return external;
1218 } 1229 }
1219 1230
1220 1231
1221 Handle<Code> Factory::NewCode(const CodeDesc& desc, 1232 Handle<Code> Factory::NewCode(const CodeDesc& desc,
1222 Code::Flags flags, 1233 Code::Flags flags,
1223 Handle<Object> self_ref, 1234 Handle<Object> self_ref,
1224 bool immovable, 1235 bool immovable,
1225 bool crankshafted, 1236 bool crankshafted,
1226 int prologue_offset) { 1237 int prologue_offset) {
1227 CALL_HEAP_FUNCTION(isolate(), 1238 CALL_HEAP_FUNCTION(isolate(),
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 if (name->Equals(h->infinity_string())) return infinity_value(); 1954 if (name->Equals(h->infinity_string())) return infinity_value();
1944 return Handle<Object>::null(); 1955 return Handle<Object>::null();
1945 } 1956 }
1946 1957
1947 1958
1948 Handle<Object> Factory::ToBoolean(bool value) { 1959 Handle<Object> Factory::ToBoolean(bool value) {
1949 return value ? true_value() : false_value(); 1960 return value ? true_value() : false_value();
1950 } 1961 }
1951 1962
1952 } } // namespace v8::internal 1963 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698