blob: 0b796350d44b6ff31e905a32b9da76aee9f175f5 [file] [log] [blame]
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "api.h"
31#include "debug.h"
32#include "execution.h"
33#include "factory.h"
34#include "macro-assembler.h"
Ben Murdochb0fe1622011-05-05 13:52:32 +010035#include "objects.h"
Iain Merrick75681382010-08-19 15:07:18 +010036#include "objects-visiting.h"
Ben Murdoch69a99ed2011-11-30 16:03:39 +000037#include "scopeinfo.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000038
39namespace v8 {
40namespace internal {
41
42
43Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) {
44 ASSERT(0 <= size);
Steve Block44f0eee2011-05-26 01:26:41 +010045 CALL_HEAP_FUNCTION(
46 isolate(),
47 isolate()->heap()->AllocateFixedArray(size, pretenure),
48 FixedArray);
Steve Blocka7e24c12009-10-30 11:49:00 +000049}
50
51
Steve Block6ded16b2010-05-10 14:33:55 +010052Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size,
53 PretenureFlag pretenure) {
Steve Blocka7e24c12009-10-30 11:49:00 +000054 ASSERT(0 <= size);
Steve Block44f0eee2011-05-26 01:26:41 +010055 CALL_HEAP_FUNCTION(
56 isolate(),
57 isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure),
58 FixedArray);
Steve Blocka7e24c12009-10-30 11:49:00 +000059}
60
61
Ben Murdoch592a9fc2012-03-05 11:04:45 +000062Handle<FixedDoubleArray> Factory::NewFixedDoubleArray(int size,
63 PretenureFlag pretenure) {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000064 ASSERT(0 <= size);
65 CALL_HEAP_FUNCTION(
66 isolate(),
67 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
Ben Murdoch592a9fc2012-03-05 11:04:45 +000068 FixedDoubleArray);
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000069}
70
71
Steve Blocka7e24c12009-10-30 11:49:00 +000072Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) {
73 ASSERT(0 <= at_least_space_for);
Steve Block44f0eee2011-05-26 01:26:41 +010074 CALL_HEAP_FUNCTION(isolate(),
75 StringDictionary::Allocate(at_least_space_for),
Steve Blocka7e24c12009-10-30 11:49:00 +000076 StringDictionary);
77}
78
79
Ben Murdochc7cc0282012-03-05 14:35:55 +000080Handle<SeededNumberDictionary> Factory::NewSeededNumberDictionary(
81 int at_least_space_for) {
Steve Blocka7e24c12009-10-30 11:49:00 +000082 ASSERT(0 <= at_least_space_for);
Steve Block44f0eee2011-05-26 01:26:41 +010083 CALL_HEAP_FUNCTION(isolate(),
Ben Murdochc7cc0282012-03-05 14:35:55 +000084 SeededNumberDictionary::Allocate(at_least_space_for),
85 SeededNumberDictionary);
86}
87
88
89Handle<UnseededNumberDictionary> Factory::NewUnseededNumberDictionary(
90 int at_least_space_for) {
91 ASSERT(0 <= at_least_space_for);
92 CALL_HEAP_FUNCTION(isolate(),
93 UnseededNumberDictionary::Allocate(at_least_space_for),
94 UnseededNumberDictionary);
Ben Murdoch2b4ba112012-01-20 14:57:15 +000095}
96
97
Ben Murdoch592a9fc2012-03-05 11:04:45 +000098Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) {
Ben Murdoch2b4ba112012-01-20 14:57:15 +000099 ASSERT(0 <= at_least_space_for);
100 CALL_HEAP_FUNCTION(isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000101 ObjectHashSet::Allocate(at_least_space_for),
102 ObjectHashSet);
Steve Blocka7e24c12009-10-30 11:49:00 +0000103}
104
105
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000106Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) {
107 ASSERT(0 <= at_least_space_for);
108 CALL_HEAP_FUNCTION(isolate(),
109 ObjectHashTable::Allocate(at_least_space_for),
110 ObjectHashTable);
111}
112
113
Steve Blocka7e24c12009-10-30 11:49:00 +0000114Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors) {
115 ASSERT(0 <= number_of_descriptors);
Steve Block44f0eee2011-05-26 01:26:41 +0100116 CALL_HEAP_FUNCTION(isolate(),
117 DescriptorArray::Allocate(number_of_descriptors),
Steve Blocka7e24c12009-10-30 11:49:00 +0000118 DescriptorArray);
119}
120
121
Ben Murdochb0fe1622011-05-05 13:52:32 +0100122Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
123 int deopt_entry_count,
124 PretenureFlag pretenure) {
125 ASSERT(deopt_entry_count > 0);
Steve Block44f0eee2011-05-26 01:26:41 +0100126 CALL_HEAP_FUNCTION(isolate(),
127 DeoptimizationInputData::Allocate(deopt_entry_count,
Ben Murdochb0fe1622011-05-05 13:52:32 +0100128 pretenure),
129 DeoptimizationInputData);
130}
131
132
133Handle<DeoptimizationOutputData> Factory::NewDeoptimizationOutputData(
134 int deopt_entry_count,
135 PretenureFlag pretenure) {
136 ASSERT(deopt_entry_count > 0);
Steve Block44f0eee2011-05-26 01:26:41 +0100137 CALL_HEAP_FUNCTION(isolate(),
138 DeoptimizationOutputData::Allocate(deopt_entry_count,
Ben Murdochb0fe1622011-05-05 13:52:32 +0100139 pretenure),
140 DeoptimizationOutputData);
141}
142
143
Ben Murdochc7cc0282012-03-05 14:35:55 +0000144Handle<AccessorPair> Factory::NewAccessorPair() {
145 CALL_HEAP_FUNCTION(isolate(),
146 isolate()->heap()->AllocateAccessorPair(),
147 AccessorPair);
148}
149
150
Steve Blocka7e24c12009-10-30 11:49:00 +0000151// Symbols are created in the old generation (data space).
152Handle<String> Factory::LookupSymbol(Vector<const char> string) {
Steve Block44f0eee2011-05-26 01:26:41 +0100153 CALL_HEAP_FUNCTION(isolate(),
154 isolate()->heap()->LookupSymbol(string),
155 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000156}
157
Ben Murdoch257744e2011-11-30 15:57:28 +0000158// Symbols are created in the old generation (data space).
159Handle<String> Factory::LookupSymbol(Handle<String> string) {
160 CALL_HEAP_FUNCTION(isolate(),
161 isolate()->heap()->LookupSymbol(*string),
162 String);
163}
164
Steve Block9fac8402011-05-12 15:51:54 +0100165Handle<String> Factory::LookupAsciiSymbol(Vector<const char> string) {
Steve Block44f0eee2011-05-26 01:26:41 +0100166 CALL_HEAP_FUNCTION(isolate(),
167 isolate()->heap()->LookupAsciiSymbol(string),
168 String);
Steve Block9fac8402011-05-12 15:51:54 +0100169}
170
Ben Murdoch257744e2011-11-30 15:57:28 +0000171
172Handle<String> Factory::LookupAsciiSymbol(Handle<SeqAsciiString> string,
173 int from,
174 int length) {
175 CALL_HEAP_FUNCTION(isolate(),
176 isolate()->heap()->LookupAsciiSymbol(string,
177 from,
178 length),
179 String);
180}
181
182
Steve Block9fac8402011-05-12 15:51:54 +0100183Handle<String> Factory::LookupTwoByteSymbol(Vector<const uc16> string) {
Steve Block44f0eee2011-05-26 01:26:41 +0100184 CALL_HEAP_FUNCTION(isolate(),
185 isolate()->heap()->LookupTwoByteSymbol(string),
186 String);
Steve Block9fac8402011-05-12 15:51:54 +0100187}
188
Steve Blocka7e24c12009-10-30 11:49:00 +0000189
190Handle<String> Factory::NewStringFromAscii(Vector<const char> string,
191 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100192 CALL_HEAP_FUNCTION(
193 isolate(),
194 isolate()->heap()->AllocateStringFromAscii(string, pretenure),
195 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000196}
197
198Handle<String> Factory::NewStringFromUtf8(Vector<const char> string,
199 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100200 CALL_HEAP_FUNCTION(
201 isolate(),
202 isolate()->heap()->AllocateStringFromUtf8(string, pretenure),
203 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000204}
205
206
207Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string,
208 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100209 CALL_HEAP_FUNCTION(
210 isolate(),
211 isolate()->heap()->AllocateStringFromTwoByte(string, pretenure),
212 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000213}
214
215
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000216Handle<SeqAsciiString> Factory::NewRawAsciiString(int length,
217 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100218 CALL_HEAP_FUNCTION(
219 isolate(),
220 isolate()->heap()->AllocateRawAsciiString(length, pretenure),
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000221 SeqAsciiString);
Leon Clarkeac952652010-07-15 11:15:24 +0100222}
223
224
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000225Handle<SeqTwoByteString> Factory::NewRawTwoByteString(int length,
226 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100227 CALL_HEAP_FUNCTION(
228 isolate(),
229 isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000230 SeqTwoByteString);
Steve Blocka7e24c12009-10-30 11:49:00 +0000231}
232
233
234Handle<String> Factory::NewConsString(Handle<String> first,
235 Handle<String> second) {
Steve Block44f0eee2011-05-26 01:26:41 +0100236 CALL_HEAP_FUNCTION(isolate(),
237 isolate()->heap()->AllocateConsString(*first, *second),
238 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000239}
240
241
Steve Blockd0582a62009-12-15 09:54:21 +0000242Handle<String> Factory::NewSubString(Handle<String> str,
243 int begin,
244 int end) {
Steve Block44f0eee2011-05-26 01:26:41 +0100245 CALL_HEAP_FUNCTION(isolate(),
246 str->SubString(begin, end),
247 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000248}
249
250
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000251Handle<String> Factory::NewProperSubString(Handle<String> str,
252 int begin,
253 int end) {
254 ASSERT(begin > 0 || end < str->length());
255 CALL_HEAP_FUNCTION(isolate(),
256 isolate()->heap()->AllocateSubString(*str, begin, end),
257 String);
258}
259
260
Steve Blocka7e24c12009-10-30 11:49:00 +0000261Handle<String> Factory::NewExternalStringFromAscii(
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000262 const ExternalAsciiString::Resource* resource) {
Steve Block44f0eee2011-05-26 01:26:41 +0100263 CALL_HEAP_FUNCTION(
264 isolate(),
265 isolate()->heap()->AllocateExternalStringFromAscii(resource),
266 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000267}
268
269
270Handle<String> Factory::NewExternalStringFromTwoByte(
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000271 const ExternalTwoByteString::Resource* resource) {
Steve Block44f0eee2011-05-26 01:26:41 +0100272 CALL_HEAP_FUNCTION(
273 isolate(),
274 isolate()->heap()->AllocateExternalStringFromTwoByte(resource),
275 String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000276}
277
278
279Handle<Context> Factory::NewGlobalContext() {
Steve Block44f0eee2011-05-26 01:26:41 +0100280 CALL_HEAP_FUNCTION(
281 isolate(),
282 isolate()->heap()->AllocateGlobalContext(),
283 Context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000284}
285
286
287Handle<Context> Factory::NewFunctionContext(int length,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000288 Handle<JSFunction> function) {
Steve Block44f0eee2011-05-26 01:26:41 +0100289 CALL_HEAP_FUNCTION(
290 isolate(),
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000291 isolate()->heap()->AllocateFunctionContext(length, *function),
Steve Block44f0eee2011-05-26 01:26:41 +0100292 Context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000293}
294
295
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000296Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function,
297 Handle<Context> previous,
298 Handle<String> name,
299 Handle<Object> thrown_object) {
Steve Block44f0eee2011-05-26 01:26:41 +0100300 CALL_HEAP_FUNCTION(
301 isolate(),
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000302 isolate()->heap()->AllocateCatchContext(*function,
303 *previous,
304 *name,
305 *thrown_object),
306 Context);
307}
308
309
310Handle<Context> Factory::NewWithContext(Handle<JSFunction> function,
311 Handle<Context> previous,
312 Handle<JSObject> extension) {
313 CALL_HEAP_FUNCTION(
314 isolate(),
315 isolate()->heap()->AllocateWithContext(*function, *previous, *extension),
Steve Block44f0eee2011-05-26 01:26:41 +0100316 Context);
Steve Blocka7e24c12009-10-30 11:49:00 +0000317}
318
319
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000320Handle<Context> Factory::NewBlockContext(
321 Handle<JSFunction> function,
322 Handle<Context> previous,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000323 Handle<ScopeInfo> scope_info) {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000324 CALL_HEAP_FUNCTION(
325 isolate(),
326 isolate()->heap()->AllocateBlockContext(*function,
327 *previous,
328 *scope_info),
329 Context);
330}
331
332
Steve Blocka7e24c12009-10-30 11:49:00 +0000333Handle<Struct> Factory::NewStruct(InstanceType type) {
Steve Block44f0eee2011-05-26 01:26:41 +0100334 CALL_HEAP_FUNCTION(
335 isolate(),
336 isolate()->heap()->AllocateStruct(type),
337 Struct);
Steve Blocka7e24c12009-10-30 11:49:00 +0000338}
339
340
341Handle<AccessorInfo> Factory::NewAccessorInfo() {
342 Handle<AccessorInfo> info =
343 Handle<AccessorInfo>::cast(NewStruct(ACCESSOR_INFO_TYPE));
344 info->set_flag(0); // Must clear the flag, it was initialized as undefined.
345 return info;
346}
347
348
349Handle<Script> Factory::NewScript(Handle<String> source) {
350 // Generate id for this script.
351 int id;
Steve Block44f0eee2011-05-26 01:26:41 +0100352 Heap* heap = isolate()->heap();
353 if (heap->last_script_id()->IsUndefined()) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000354 // Script ids start from one.
355 id = 1;
356 } else {
357 // Increment id, wrap when positive smi is exhausted.
Steve Block44f0eee2011-05-26 01:26:41 +0100358 id = Smi::cast(heap->last_script_id())->value();
Steve Blocka7e24c12009-10-30 11:49:00 +0000359 id++;
360 if (!Smi::IsValid(id)) {
361 id = 0;
362 }
363 }
Steve Block44f0eee2011-05-26 01:26:41 +0100364 heap->SetLastScriptId(Smi::FromInt(id));
Steve Blocka7e24c12009-10-30 11:49:00 +0000365
366 // Create and initialize script object.
Ben Murdoch257744e2011-11-30 15:57:28 +0000367 Handle<Foreign> wrapper = NewForeign(0, TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000368 Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
369 script->set_source(*source);
Steve Block44f0eee2011-05-26 01:26:41 +0100370 script->set_name(heap->undefined_value());
371 script->set_id(heap->last_script_id());
Steve Blocka7e24c12009-10-30 11:49:00 +0000372 script->set_line_offset(Smi::FromInt(0));
373 script->set_column_offset(Smi::FromInt(0));
Steve Block44f0eee2011-05-26 01:26:41 +0100374 script->set_data(heap->undefined_value());
375 script->set_context_data(heap->undefined_value());
Steve Blocka7e24c12009-10-30 11:49:00 +0000376 script->set_type(Smi::FromInt(Script::TYPE_NORMAL));
377 script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST));
378 script->set_wrapper(*wrapper);
Steve Block44f0eee2011-05-26 01:26:41 +0100379 script->set_line_ends(heap->undefined_value());
380 script->set_eval_from_shared(heap->undefined_value());
Steve Blocka7e24c12009-10-30 11:49:00 +0000381 script->set_eval_from_instructions_offset(Smi::FromInt(0));
382
383 return script;
384}
385
386
Ben Murdoch257744e2011-11-30 15:57:28 +0000387Handle<Foreign> Factory::NewForeign(Address addr, PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100388 CALL_HEAP_FUNCTION(isolate(),
Ben Murdoch257744e2011-11-30 15:57:28 +0000389 isolate()->heap()->AllocateForeign(addr, pretenure),
390 Foreign);
Steve Blocka7e24c12009-10-30 11:49:00 +0000391}
392
393
Ben Murdoch257744e2011-11-30 15:57:28 +0000394Handle<Foreign> Factory::NewForeign(const AccessorDescriptor* desc) {
395 return NewForeign((Address) desc, TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000396}
397
398
399Handle<ByteArray> Factory::NewByteArray(int length, PretenureFlag pretenure) {
400 ASSERT(0 <= length);
Steve Block44f0eee2011-05-26 01:26:41 +0100401 CALL_HEAP_FUNCTION(
402 isolate(),
403 isolate()->heap()->AllocateByteArray(length, pretenure),
404 ByteArray);
Steve Blocka7e24c12009-10-30 11:49:00 +0000405}
406
407
Steve Block3ce2e202009-11-05 08:53:23 +0000408Handle<ExternalArray> Factory::NewExternalArray(int length,
409 ExternalArrayType array_type,
410 void* external_pointer,
411 PretenureFlag pretenure) {
412 ASSERT(0 <= length);
Steve Block44f0eee2011-05-26 01:26:41 +0100413 CALL_HEAP_FUNCTION(
414 isolate(),
415 isolate()->heap()->AllocateExternalArray(length,
416 array_type,
417 external_pointer,
418 pretenure),
419 ExternalArray);
Steve Block3ce2e202009-11-05 08:53:23 +0000420}
421
422
Ben Murdochb0fe1622011-05-05 13:52:32 +0100423Handle<JSGlobalPropertyCell> Factory::NewJSGlobalPropertyCell(
424 Handle<Object> value) {
Steve Block44f0eee2011-05-26 01:26:41 +0100425 CALL_HEAP_FUNCTION(
426 isolate(),
427 isolate()->heap()->AllocateJSGlobalPropertyCell(*value),
428 JSGlobalPropertyCell);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100429}
430
431
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000432Handle<Map> Factory::NewMap(InstanceType type,
433 int instance_size,
434 ElementsKind elements_kind) {
Steve Block44f0eee2011-05-26 01:26:41 +0100435 CALL_HEAP_FUNCTION(
436 isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000437 isolate()->heap()->AllocateMap(type, instance_size, elements_kind),
Steve Block44f0eee2011-05-26 01:26:41 +0100438 Map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000439}
440
441
442Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
Steve Block44f0eee2011-05-26 01:26:41 +0100443 CALL_HEAP_FUNCTION(
444 isolate(),
445 isolate()->heap()->AllocateFunctionPrototype(*function),
446 JSObject);
Steve Blocka7e24c12009-10-30 11:49:00 +0000447}
448
449
450Handle<Map> Factory::CopyMapDropDescriptors(Handle<Map> src) {
Steve Block44f0eee2011-05-26 01:26:41 +0100451 CALL_HEAP_FUNCTION(isolate(), src->CopyDropDescriptors(), Map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000452}
453
454
455Handle<Map> Factory::CopyMap(Handle<Map> src,
456 int extra_inobject_properties) {
457 Handle<Map> copy = CopyMapDropDescriptors(src);
458 // Check that we do not overflow the instance size when adding the
459 // extra inobject properties.
460 int instance_size_delta = extra_inobject_properties * kPointerSize;
461 int max_instance_size_delta =
462 JSObject::kMaxInstanceSize - copy->instance_size();
463 if (instance_size_delta > max_instance_size_delta) {
464 // If the instance size overflows, we allocate as many properties
465 // as we can as inobject properties.
466 instance_size_delta = max_instance_size_delta;
467 extra_inobject_properties = max_instance_size_delta >> kPointerSizeLog2;
468 }
469 // Adjust the map with the extra inobject properties.
470 int inobject_properties =
471 copy->inobject_properties() + extra_inobject_properties;
472 copy->set_inobject_properties(inobject_properties);
473 copy->set_unused_property_fields(inobject_properties);
474 copy->set_instance_size(copy->instance_size() + instance_size_delta);
Iain Merrick75681382010-08-19 15:07:18 +0100475 copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
Steve Blocka7e24c12009-10-30 11:49:00 +0000476 return copy;
477}
478
Steve Block8defd9f2010-07-08 12:39:36 +0100479
Steve Blocka7e24c12009-10-30 11:49:00 +0000480Handle<Map> Factory::CopyMapDropTransitions(Handle<Map> src) {
Steve Block44f0eee2011-05-26 01:26:41 +0100481 CALL_HEAP_FUNCTION(isolate(), src->CopyDropTransitions(), Map);
Steve Blocka7e24c12009-10-30 11:49:00 +0000482}
483
484
Ben Murdoch589d6972011-11-30 16:04:58 +0000485Handle<Map> Factory::GetElementsTransitionMap(
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000486 Handle<JSObject> src,
487 ElementsKind elements_kind) {
Steve Block44f0eee2011-05-26 01:26:41 +0100488 CALL_HEAP_FUNCTION(isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000489 src->GetElementsTransitionMap(elements_kind),
Steve Block44f0eee2011-05-26 01:26:41 +0100490 Map);
Steve Block1e0659c2011-05-24 12:43:12 +0100491}
492
493
Steve Blocka7e24c12009-10-30 11:49:00 +0000494Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
Steve Block44f0eee2011-05-26 01:26:41 +0100495 CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray);
Steve Blocka7e24c12009-10-30 11:49:00 +0000496}
497
498
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000499Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
500 Handle<FixedDoubleArray> array) {
501 CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedDoubleArray);
502}
503
504
Steve Block6ded16b2010-05-10 14:33:55 +0100505Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo(
506 Handle<SharedFunctionInfo> function_info,
Leon Clarkee46be812010-01-19 14:06:41 +0000507 Handle<Map> function_map,
508 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100509 CALL_HEAP_FUNCTION(
510 isolate(),
511 isolate()->heap()->AllocateFunction(*function_map,
512 *function_info,
513 isolate()->heap()->the_hole_value(),
514 pretenure),
Steve Blocka7e24c12009-10-30 11:49:00 +0000515 JSFunction);
516}
517
518
Steve Block6ded16b2010-05-10 14:33:55 +0100519Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
520 Handle<SharedFunctionInfo> function_info,
Leon Clarkee46be812010-01-19 14:06:41 +0000521 Handle<Context> context,
522 PretenureFlag pretenure) {
Steve Block6ded16b2010-05-10 14:33:55 +0100523 Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
Steve Block44f0eee2011-05-26 01:26:41 +0100524 function_info,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000525 function_info->is_classic_mode()
526 ? isolate()->function_map()
527 : isolate()->strict_mode_function_map(),
Steve Block44f0eee2011-05-26 01:26:41 +0100528 pretenure);
529
Steve Blocka7e24c12009-10-30 11:49:00 +0000530 result->set_context(*context);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000531 if (!function_info->bound()) {
532 int number_of_literals = function_info->num_literals();
533 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
534 if (number_of_literals > 0) {
535 // Store the object, regexp and array functions in the literals
536 // array prefix. These functions will be used when creating
537 // object, regexp and array literals in this function.
538 literals->set(JSFunction::kLiteralGlobalContextIndex,
539 context->global_context());
540 }
541 result->set_literals(*literals);
542 } else {
543 result->set_function_bindings(isolate()->heap()->empty_fixed_array());
Steve Blocka7e24c12009-10-30 11:49:00 +0000544 }
Steve Block44f0eee2011-05-26 01:26:41 +0100545 result->set_next_function_link(isolate()->heap()->undefined_value());
Ben Murdochb0fe1622011-05-05 13:52:32 +0100546
547 if (V8::UseCrankshaft() &&
548 FLAG_always_opt &&
549 result->is_compiled() &&
550 !function_info->is_toplevel() &&
551 function_info->allows_lazy_compilation()) {
552 result->MarkForLazyRecompilation();
553 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000554 return result;
555}
556
557
558Handle<Object> Factory::NewNumber(double value,
559 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100560 CALL_HEAP_FUNCTION(
561 isolate(),
562 isolate()->heap()->NumberFromDouble(value, pretenure), Object);
Steve Blocka7e24c12009-10-30 11:49:00 +0000563}
564
565
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000566Handle<Object> Factory::NewNumberFromInt(int32_t value,
567 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100568 CALL_HEAP_FUNCTION(
569 isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000570 isolate()->heap()->NumberFromInt32(value, pretenure), Object);
Steve Blocka7e24c12009-10-30 11:49:00 +0000571}
572
573
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000574Handle<Object> Factory::NewNumberFromUint(uint32_t value,
575 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100576 CALL_HEAP_FUNCTION(
577 isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000578 isolate()->heap()->NumberFromUint32(value, pretenure), Object);
Steve Blocka7e24c12009-10-30 11:49:00 +0000579}
580
581
582Handle<JSObject> Factory::NewNeanderObject() {
Steve Block44f0eee2011-05-26 01:26:41 +0100583 CALL_HEAP_FUNCTION(
584 isolate(),
585 isolate()->heap()->AllocateJSObjectFromMap(
586 isolate()->heap()->neander_map()),
587 JSObject);
Steve Blocka7e24c12009-10-30 11:49:00 +0000588}
589
590
591Handle<Object> Factory::NewTypeError(const char* type,
592 Vector< Handle<Object> > args) {
593 return NewError("MakeTypeError", type, args);
594}
595
596
597Handle<Object> Factory::NewTypeError(Handle<String> message) {
598 return NewError("$TypeError", message);
599}
600
601
602Handle<Object> Factory::NewRangeError(const char* type,
603 Vector< Handle<Object> > args) {
604 return NewError("MakeRangeError", type, args);
605}
606
607
608Handle<Object> Factory::NewRangeError(Handle<String> message) {
609 return NewError("$RangeError", message);
610}
611
612
613Handle<Object> Factory::NewSyntaxError(const char* type, Handle<JSArray> args) {
614 return NewError("MakeSyntaxError", type, args);
615}
616
617
618Handle<Object> Factory::NewSyntaxError(Handle<String> message) {
619 return NewError("$SyntaxError", message);
620}
621
622
623Handle<Object> Factory::NewReferenceError(const char* type,
624 Vector< Handle<Object> > args) {
625 return NewError("MakeReferenceError", type, args);
626}
627
628
629Handle<Object> Factory::NewReferenceError(Handle<String> message) {
630 return NewError("$ReferenceError", message);
631}
632
633
634Handle<Object> Factory::NewError(const char* maker, const char* type,
635 Vector< Handle<Object> > args) {
636 v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom.
Steve Block44f0eee2011-05-26 01:26:41 +0100637 Handle<FixedArray> array = NewFixedArray(args.length());
Steve Blocka7e24c12009-10-30 11:49:00 +0000638 for (int i = 0; i < args.length(); i++) {
639 array->set(i, *args[i]);
640 }
Steve Block44f0eee2011-05-26 01:26:41 +0100641 Handle<JSArray> object = NewJSArrayWithElements(array);
Steve Blocka7e24c12009-10-30 11:49:00 +0000642 Handle<Object> result = NewError(maker, type, object);
643 return result.EscapeFrom(&scope);
644}
645
646
647Handle<Object> Factory::NewEvalError(const char* type,
648 Vector< Handle<Object> > args) {
649 return NewError("MakeEvalError", type, args);
650}
651
652
653Handle<Object> Factory::NewError(const char* type,
654 Vector< Handle<Object> > args) {
655 return NewError("MakeError", type, args);
656}
657
658
659Handle<Object> Factory::NewError(const char* maker,
660 const char* type,
661 Handle<JSArray> args) {
Steve Block44f0eee2011-05-26 01:26:41 +0100662 Handle<String> make_str = LookupAsciiSymbol(maker);
663 Handle<Object> fun_obj(
664 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str));
Steve Blocka7e24c12009-10-30 11:49:00 +0000665 // If the builtins haven't been properly configured yet this error
666 // constructor may not have been defined. Bail out.
667 if (!fun_obj->IsJSFunction())
Steve Block44f0eee2011-05-26 01:26:41 +0100668 return undefined_value();
Steve Blocka7e24c12009-10-30 11:49:00 +0000669 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
Steve Block44f0eee2011-05-26 01:26:41 +0100670 Handle<Object> type_obj = LookupAsciiSymbol(type);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000671 Handle<Object> argv[] = { type_obj, args };
Steve Blocka7e24c12009-10-30 11:49:00 +0000672
673 // Invoke the JavaScript factory method. If an exception is thrown while
674 // running the factory method, use the exception as the result.
675 bool caught_exception;
676 Handle<Object> result = Execution::TryCall(fun,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000677 isolate()->js_builtins_object(),
678 ARRAY_SIZE(argv),
679 argv,
680 &caught_exception);
Steve Blocka7e24c12009-10-30 11:49:00 +0000681 return result;
682}
683
684
685Handle<Object> Factory::NewError(Handle<String> message) {
686 return NewError("$Error", message);
687}
688
689
690Handle<Object> Factory::NewError(const char* constructor,
691 Handle<String> message) {
Steve Block44f0eee2011-05-26 01:26:41 +0100692 Handle<String> constr = LookupAsciiSymbol(constructor);
693 Handle<JSFunction> fun = Handle<JSFunction>(
694 JSFunction::cast(isolate()->js_builtins_object()->
695 GetPropertyNoExceptionThrown(*constr)));
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000696 Handle<Object> argv[] = { message };
Steve Blocka7e24c12009-10-30 11:49:00 +0000697
698 // Invoke the JavaScript factory method. If an exception is thrown while
699 // running the factory method, use the exception as the result.
700 bool caught_exception;
701 Handle<Object> result = Execution::TryCall(fun,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000702 isolate()->js_builtins_object(),
703 ARRAY_SIZE(argv),
704 argv,
705 &caught_exception);
Steve Blocka7e24c12009-10-30 11:49:00 +0000706 return result;
707}
708
709
710Handle<JSFunction> Factory::NewFunction(Handle<String> name,
711 InstanceType type,
712 int instance_size,
713 Handle<Code> code,
714 bool force_initial_map) {
715 // Allocate the function
716 Handle<JSFunction> function = NewFunction(name, the_hole_value());
Iain Merrick75681382010-08-19 15:07:18 +0100717
Ben Murdochc7cc0282012-03-05 14:35:55 +0000718 // Set up the code pointer in both the shared function info and in
Iain Merrick75681382010-08-19 15:07:18 +0100719 // the function itself.
720 function->shared()->set_code(*code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000721 function->set_code(*code);
722
723 if (force_initial_map ||
724 type != JS_OBJECT_TYPE ||
725 instance_size != JSObject::kHeaderSize) {
726 Handle<Map> initial_map = NewMap(type, instance_size);
727 Handle<JSObject> prototype = NewFunctionPrototype(function);
728 initial_map->set_prototype(*prototype);
729 function->set_initial_map(*initial_map);
730 initial_map->set_constructor(*function);
731 } else {
732 ASSERT(!function->has_initial_map());
733 ASSERT(!function->has_prototype());
734 }
735
736 return function;
737}
738
739
Steve Blocka7e24c12009-10-30 11:49:00 +0000740Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
741 InstanceType type,
742 int instance_size,
743 Handle<JSObject> prototype,
744 Handle<Code> code,
745 bool force_initial_map) {
Iain Merrick75681382010-08-19 15:07:18 +0100746 // Allocate the function.
Steve Blocka7e24c12009-10-30 11:49:00 +0000747 Handle<JSFunction> function = NewFunction(name, prototype);
748
Ben Murdochc7cc0282012-03-05 14:35:55 +0000749 // Set up the code pointer in both the shared function info and in
Iain Merrick75681382010-08-19 15:07:18 +0100750 // the function itself.
751 function->shared()->set_code(*code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000752 function->set_code(*code);
753
754 if (force_initial_map ||
755 type != JS_OBJECT_TYPE ||
756 instance_size != JSObject::kHeaderSize) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000757 ElementsKind default_elements_kind = FLAG_smi_only_arrays
758 ? FAST_SMI_ONLY_ELEMENTS
759 : FAST_ELEMENTS;
760 Handle<Map> initial_map = NewMap(type,
761 instance_size,
762 default_elements_kind);
Steve Blocka7e24c12009-10-30 11:49:00 +0000763 function->set_initial_map(*initial_map);
764 initial_map->set_constructor(*function);
765 }
766
767 // Set function.prototype and give the prototype a constructor
768 // property that refers to the function.
769 SetPrototypeProperty(function, prototype);
Steve Block1e0659c2011-05-24 12:43:12 +0100770 // Currently safe because it is only invoked from Genesis.
Ben Murdochc7cc0282012-03-05 14:35:55 +0000771 CHECK_NOT_EMPTY_HANDLE(isolate(),
772 JSObject::SetLocalPropertyIgnoreAttributes(
773 prototype, constructor_symbol(),
774 function, DONT_ENUM));
Steve Blocka7e24c12009-10-30 11:49:00 +0000775 return function;
776}
777
778
Steve Block6ded16b2010-05-10 14:33:55 +0100779Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name,
780 Handle<Code> code) {
Steve Block44f0eee2011-05-26 01:26:41 +0100781 Handle<JSFunction> function = NewFunctionWithoutPrototype(name,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000782 CLASSIC_MODE);
Iain Merrick75681382010-08-19 15:07:18 +0100783 function->shared()->set_code(*code);
Steve Block6ded16b2010-05-10 14:33:55 +0100784 function->set_code(*code);
785 ASSERT(!function->has_initial_map());
786 ASSERT(!function->has_prototype());
787 return function;
788}
789
790
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000791Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000792 CALL_HEAP_FUNCTION(
793 isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000794 isolate()->heap()->AllocateScopeInfo(length),
795 ScopeInfo);
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000796}
797
798
Steve Blocka7e24c12009-10-30 11:49:00 +0000799Handle<Code> Factory::NewCode(const CodeDesc& desc,
Steve Blocka7e24c12009-10-30 11:49:00 +0000800 Code::Flags flags,
Steve Block44f0eee2011-05-26 01:26:41 +0100801 Handle<Object> self_ref,
802 bool immovable) {
803 CALL_HEAP_FUNCTION(isolate(),
804 isolate()->heap()->CreateCode(
805 desc, flags, self_ref, immovable),
806 Code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000807}
808
809
810Handle<Code> Factory::CopyCode(Handle<Code> code) {
Steve Block44f0eee2011-05-26 01:26:41 +0100811 CALL_HEAP_FUNCTION(isolate(),
812 isolate()->heap()->CopyCode(*code),
813 Code);
Steve Blocka7e24c12009-10-30 11:49:00 +0000814}
815
816
Steve Block6ded16b2010-05-10 14:33:55 +0100817Handle<Code> Factory::CopyCode(Handle<Code> code, Vector<byte> reloc_info) {
Steve Block44f0eee2011-05-26 01:26:41 +0100818 CALL_HEAP_FUNCTION(isolate(),
819 isolate()->heap()->CopyCode(*code, reloc_info),
820 Code);
Steve Block6ded16b2010-05-10 14:33:55 +0100821}
822
823
John Reck59135872010-11-02 12:39:01 -0700824MUST_USE_RESULT static inline MaybeObject* DoCopyInsert(
825 DescriptorArray* array,
826 String* key,
827 Object* value,
828 PropertyAttributes attributes) {
Steve Blocka7e24c12009-10-30 11:49:00 +0000829 CallbacksDescriptor desc(key, value, attributes);
John Reck59135872010-11-02 12:39:01 -0700830 MaybeObject* obj = array->CopyInsert(&desc, REMOVE_TRANSITIONS);
Steve Blocka7e24c12009-10-30 11:49:00 +0000831 return obj;
832}
833
834
835// Allocate the new array.
Ben Murdoch257744e2011-11-30 15:57:28 +0000836Handle<DescriptorArray> Factory::CopyAppendForeignDescriptor(
Steve Blocka7e24c12009-10-30 11:49:00 +0000837 Handle<DescriptorArray> array,
838 Handle<String> key,
839 Handle<Object> value,
840 PropertyAttributes attributes) {
Steve Block44f0eee2011-05-26 01:26:41 +0100841 CALL_HEAP_FUNCTION(isolate(),
842 DoCopyInsert(*array, *key, *value, attributes),
Steve Blocka7e24c12009-10-30 11:49:00 +0000843 DescriptorArray);
844}
845
846
847Handle<String> Factory::SymbolFromString(Handle<String> value) {
Steve Block44f0eee2011-05-26 01:26:41 +0100848 CALL_HEAP_FUNCTION(isolate(),
849 isolate()->heap()->LookupSymbol(*value), String);
Steve Blocka7e24c12009-10-30 11:49:00 +0000850}
851
852
853Handle<DescriptorArray> Factory::CopyAppendCallbackDescriptors(
854 Handle<DescriptorArray> array,
855 Handle<Object> descriptors) {
856 v8::NeanderArray callbacks(descriptors);
857 int nof_callbacks = callbacks.length();
858 Handle<DescriptorArray> result =
859 NewDescriptorArray(array->number_of_descriptors() + nof_callbacks);
860
861 // Number of descriptors added to the result so far.
862 int descriptor_count = 0;
863
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000864 // Ensure that marking will not progress and change color of objects.
865 DescriptorArray::WhitenessWitness witness(*result);
866
Steve Blocka7e24c12009-10-30 11:49:00 +0000867 // Copy the descriptors from the array.
868 for (int i = 0; i < array->number_of_descriptors(); i++) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000869 if (!array->IsNullDescriptor(i)) {
870 result->CopyFrom(descriptor_count++, *array, i, witness);
Steve Blocka7e24c12009-10-30 11:49:00 +0000871 }
872 }
873
874 // Number of duplicates detected.
875 int duplicates = 0;
876
877 // Fill in new callback descriptors. Process the callbacks from
878 // back to front so that the last callback with a given name takes
879 // precedence over previously added callbacks with that name.
880 for (int i = nof_callbacks - 1; i >= 0; i--) {
881 Handle<AccessorInfo> entry =
882 Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i)));
883 // Ensure the key is a symbol before writing into the instance descriptor.
884 Handle<String> key =
885 SymbolFromString(Handle<String>(String::cast(entry->name())));
886 // Check if a descriptor with this name already exists before writing.
887 if (result->LinearSearch(*key, descriptor_count) ==
888 DescriptorArray::kNotFound) {
889 CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000890 result->Set(descriptor_count, &desc, witness);
Steve Blocka7e24c12009-10-30 11:49:00 +0000891 descriptor_count++;
892 } else {
893 duplicates++;
894 }
895 }
896
897 // If duplicates were detected, allocate a result of the right size
898 // and transfer the elements.
899 if (duplicates > 0) {
900 int number_of_descriptors = result->number_of_descriptors() - duplicates;
901 Handle<DescriptorArray> new_result =
902 NewDescriptorArray(number_of_descriptors);
903 for (int i = 0; i < number_of_descriptors; i++) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000904 new_result->CopyFrom(i, *result, i, witness);
Steve Blocka7e24c12009-10-30 11:49:00 +0000905 }
906 result = new_result;
907 }
908
909 // Sort the result before returning.
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000910 result->Sort(witness);
Steve Blocka7e24c12009-10-30 11:49:00 +0000911 return result;
912}
913
914
915Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
916 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100917 CALL_HEAP_FUNCTION(
918 isolate(),
919 isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
Steve Blocka7e24c12009-10-30 11:49:00 +0000920}
921
922
923Handle<GlobalObject> Factory::NewGlobalObject(
924 Handle<JSFunction> constructor) {
Steve Block44f0eee2011-05-26 01:26:41 +0100925 CALL_HEAP_FUNCTION(isolate(),
926 isolate()->heap()->AllocateGlobalObject(*constructor),
Steve Blocka7e24c12009-10-30 11:49:00 +0000927 GlobalObject);
928}
929
930
931
932Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map) {
Steve Block44f0eee2011-05-26 01:26:41 +0100933 CALL_HEAP_FUNCTION(
934 isolate(),
935 isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED),
936 JSObject);
Steve Blocka7e24c12009-10-30 11:49:00 +0000937}
938
939
Steve Block44f0eee2011-05-26 01:26:41 +0100940Handle<JSArray> Factory::NewJSArray(int capacity,
Steve Blocka7e24c12009-10-30 11:49:00 +0000941 PretenureFlag pretenure) {
Steve Block44f0eee2011-05-26 01:26:41 +0100942 Handle<JSObject> obj = NewJSObject(isolate()->array_function(), pretenure);
943 CALL_HEAP_FUNCTION(isolate(),
944 Handle<JSArray>::cast(obj)->Initialize(capacity),
945 JSArray);
Steve Blocka7e24c12009-10-30 11:49:00 +0000946}
947
948
Ben Murdochc7cc0282012-03-05 14:35:55 +0000949Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
Steve Blocka7e24c12009-10-30 11:49:00 +0000950 PretenureFlag pretenure) {
951 Handle<JSArray> result =
Steve Block44f0eee2011-05-26 01:26:41 +0100952 Handle<JSArray>::cast(NewJSObject(isolate()->array_function(),
953 pretenure));
Ben Murdochc7cc0282012-03-05 14:35:55 +0000954 result->set_length(Smi::FromInt(0));
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000955 SetContent(result, elements);
Steve Blocka7e24c12009-10-30 11:49:00 +0000956 return result;
957}
958
959
Ben Murdochc7cc0282012-03-05 14:35:55 +0000960void Factory::SetElementsCapacityAndLength(Handle<JSArray> array,
961 int capacity,
962 int length) {
963 ElementsAccessor* accessor = array->GetElementsAccessor();
964 CALL_HEAP_FUNCTION_VOID(
965 isolate(),
966 accessor->SetCapacityAndLength(*array, capacity, length));
967}
968
969
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000970void Factory::SetContent(Handle<JSArray> array,
Ben Murdochc7cc0282012-03-05 14:35:55 +0000971 Handle<FixedArrayBase> elements) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000972 CALL_HEAP_FUNCTION_VOID(
973 isolate(),
974 array->SetContent(*elements));
975}
976
977
Ben Murdochc7cc0282012-03-05 14:35:55 +0000978void Factory::EnsureCanContainHeapObjectElements(Handle<JSArray> array) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000979 CALL_HEAP_FUNCTION_VOID(
980 isolate(),
Ben Murdochc7cc0282012-03-05 14:35:55 +0000981 array->EnsureCanContainHeapObjectElements());
982}
983
984
985void Factory::EnsureCanContainElements(Handle<JSArray> array,
986 Handle<FixedArrayBase> elements,
987 EnsureElementsMode mode) {
988 CALL_HEAP_FUNCTION_VOID(
989 isolate(),
990 array->EnsureCanContainElements(*elements, mode));
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000991}
992
993
Ben Murdoch257744e2011-11-30 15:57:28 +0000994Handle<JSProxy> Factory::NewJSProxy(Handle<Object> handler,
995 Handle<Object> prototype) {
996 CALL_HEAP_FUNCTION(
997 isolate(),
998 isolate()->heap()->AllocateJSProxy(*handler, *prototype),
999 JSProxy);
1000}
1001
1002
Ben Murdoch589d6972011-11-30 16:04:58 +00001003void Factory::BecomeJSObject(Handle<JSReceiver> object) {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001004 CALL_HEAP_FUNCTION_VOID(
1005 isolate(),
Ben Murdoch589d6972011-11-30 16:04:58 +00001006 isolate()->heap()->ReinitializeJSReceiver(
1007 *object, JS_OBJECT_TYPE, JSObject::kHeaderSize));
1008}
1009
1010
1011void Factory::BecomeJSFunction(Handle<JSReceiver> object) {
1012 CALL_HEAP_FUNCTION_VOID(
1013 isolate(),
1014 isolate()->heap()->ReinitializeJSReceiver(
1015 *object, JS_FUNCTION_TYPE, JSFunction::kSize));
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001016}
1017
1018
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001019void Factory::SetIdentityHash(Handle<JSObject> object, Object* hash) {
1020 CALL_HEAP_FUNCTION_VOID(
1021 isolate(),
1022 object->SetIdentityHash(hash, ALLOW_CREATION));
1023}
1024
1025
Steve Block6ded16b2010-05-10 14:33:55 +01001026Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
Ben Murdoch3bec4d22010-07-22 14:51:16 +01001027 Handle<String> name,
1028 int number_of_literals,
1029 Handle<Code> code,
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001030 Handle<ScopeInfo> scope_info) {
Steve Block6ded16b2010-05-10 14:33:55 +01001031 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name);
1032 shared->set_code(*code);
Ben Murdoch3bec4d22010-07-22 14:51:16 +01001033 shared->set_scope_info(*scope_info);
Steve Block6ded16b2010-05-10 14:33:55 +01001034 int literals_array_size = number_of_literals;
1035 // If the function contains object, regexp or array literals,
1036 // allocate extra space for a literals array prefix containing the
1037 // context.
1038 if (number_of_literals > 0) {
1039 literals_array_size += JSFunction::kLiteralsPrefixSize;
1040 }
1041 shared->set_num_literals(literals_array_size);
1042 return shared;
1043}
1044
1045
Steve Block1e0659c2011-05-24 12:43:12 +01001046Handle<JSMessageObject> Factory::NewJSMessageObject(
1047 Handle<String> type,
1048 Handle<JSArray> arguments,
1049 int start_position,
1050 int end_position,
1051 Handle<Object> script,
1052 Handle<Object> stack_trace,
1053 Handle<Object> stack_frames) {
Steve Block44f0eee2011-05-26 01:26:41 +01001054 CALL_HEAP_FUNCTION(isolate(),
1055 isolate()->heap()->AllocateJSMessageObject(*type,
1056 *arguments,
1057 start_position,
1058 end_position,
1059 *script,
1060 *stack_trace,
1061 *stack_frames),
Steve Block1e0659c2011-05-24 12:43:12 +01001062 JSMessageObject);
1063}
1064
Steve Blocka7e24c12009-10-30 11:49:00 +00001065Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(Handle<String> name) {
Steve Block44f0eee2011-05-26 01:26:41 +01001066 CALL_HEAP_FUNCTION(isolate(),
1067 isolate()->heap()->AllocateSharedFunctionInfo(*name),
Steve Blocka7e24c12009-10-30 11:49:00 +00001068 SharedFunctionInfo);
1069}
1070
1071
1072Handle<String> Factory::NumberToString(Handle<Object> number) {
Steve Block44f0eee2011-05-26 01:26:41 +01001073 CALL_HEAP_FUNCTION(isolate(),
1074 isolate()->heap()->NumberToString(*number), String);
Steve Blocka7e24c12009-10-30 11:49:00 +00001075}
1076
1077
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001078Handle<String> Factory::Uint32ToString(uint32_t value) {
Steve Block44f0eee2011-05-26 01:26:41 +01001079 CALL_HEAP_FUNCTION(isolate(),
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001080 isolate()->heap()->Uint32ToString(value), String);
Ben Murdoch2b4ba112012-01-20 14:57:15 +00001081}
1082
1083
Ben Murdochc7cc0282012-03-05 14:35:55 +00001084Handle<SeededNumberDictionary> Factory::DictionaryAtNumberPut(
1085 Handle<SeededNumberDictionary> dictionary,
Ben Murdoch2b4ba112012-01-20 14:57:15 +00001086 uint32_t key,
1087 Handle<Object> value) {
1088 CALL_HEAP_FUNCTION(isolate(),
1089 dictionary->AtNumberPut(key, *value),
Ben Murdochc7cc0282012-03-05 14:35:55 +00001090 SeededNumberDictionary);
1091}
1092
1093
1094Handle<UnseededNumberDictionary> Factory::DictionaryAtNumberPut(
1095 Handle<UnseededNumberDictionary> dictionary,
1096 uint32_t key,
1097 Handle<Object> value) {
1098 CALL_HEAP_FUNCTION(isolate(),
1099 dictionary->AtNumberPut(key, *value),
1100 UnseededNumberDictionary);
Steve Blocka7e24c12009-10-30 11:49:00 +00001101}
1102
1103
1104Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name,
1105 Handle<Object> prototype) {
1106 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
Steve Block44f0eee2011-05-26 01:26:41 +01001107 CALL_HEAP_FUNCTION(
1108 isolate(),
1109 isolate()->heap()->AllocateFunction(*isolate()->function_map(),
1110 *function_share,
1111 *prototype),
1112 JSFunction);
Steve Blocka7e24c12009-10-30 11:49:00 +00001113}
1114
1115
1116Handle<JSFunction> Factory::NewFunction(Handle<String> name,
1117 Handle<Object> prototype) {
1118 Handle<JSFunction> fun = NewFunctionHelper(name, prototype);
Steve Block44f0eee2011-05-26 01:26:41 +01001119 fun->set_context(isolate()->context()->global_context());
Steve Blocka7e24c12009-10-30 11:49:00 +00001120 return fun;
1121}
1122
1123
Steve Block6ded16b2010-05-10 14:33:55 +01001124Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
Steve Block44f0eee2011-05-26 01:26:41 +01001125 Handle<String> name,
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001126 LanguageMode language_mode) {
Steve Block6ded16b2010-05-10 14:33:55 +01001127 Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001128 Handle<Map> map = (language_mode == CLASSIC_MODE)
1129 ? isolate()->function_without_prototype_map()
1130 : isolate()->strict_mode_function_without_prototype_map();
Steve Block44f0eee2011-05-26 01:26:41 +01001131 CALL_HEAP_FUNCTION(isolate(),
1132 isolate()->heap()->AllocateFunction(
1133 *map,
Steve Block6ded16b2010-05-10 14:33:55 +01001134 *function_share,
1135 *the_hole_value()),
1136 JSFunction);
1137}
1138
1139
Steve Block44f0eee2011-05-26 01:26:41 +01001140Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
1141 Handle<String> name,
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001142 LanguageMode language_mode) {
1143 Handle<JSFunction> fun =
1144 NewFunctionWithoutPrototypeHelper(name, language_mode);
Steve Block44f0eee2011-05-26 01:26:41 +01001145 fun->set_context(isolate()->context()->global_context());
Steve Block6ded16b2010-05-10 14:33:55 +01001146 return fun;
1147}
1148
1149
Leon Clarkee46be812010-01-19 14:06:41 +00001150Handle<Object> Factory::ToObject(Handle<Object> object) {
Steve Block44f0eee2011-05-26 01:26:41 +01001151 CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object);
Leon Clarkee46be812010-01-19 14:06:41 +00001152}
1153
1154
Steve Blocka7e24c12009-10-30 11:49:00 +00001155Handle<Object> Factory::ToObject(Handle<Object> object,
1156 Handle<Context> global_context) {
Steve Block44f0eee2011-05-26 01:26:41 +01001157 CALL_HEAP_FUNCTION(isolate(), object->ToObject(*global_context), Object);
Steve Blocka7e24c12009-10-30 11:49:00 +00001158}
1159
1160
1161#ifdef ENABLE_DEBUGGER_SUPPORT
1162Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
1163 // Get the original code of the function.
1164 Handle<Code> code(shared->code());
1165
1166 // Create a copy of the code before allocating the debug info object to avoid
1167 // allocation while setting up the debug info object.
1168 Handle<Code> original_code(*Factory::CopyCode(code));
1169
1170 // Allocate initial fixed array for active break points before allocating the
1171 // debug info object to avoid allocation while setting up the debug info
1172 // object.
1173 Handle<FixedArray> break_points(
Steve Block44f0eee2011-05-26 01:26:41 +01001174 NewFixedArray(Debug::kEstimatedNofBreakPointsInFunction));
Steve Blocka7e24c12009-10-30 11:49:00 +00001175
1176 // Create and set up the debug info object. Debug info contains function, a
1177 // copy of the original code, the executing code and initial fixed array for
1178 // active break points.
1179 Handle<DebugInfo> debug_info =
Steve Block44f0eee2011-05-26 01:26:41 +01001180 Handle<DebugInfo>::cast(NewStruct(DEBUG_INFO_TYPE));
Steve Blocka7e24c12009-10-30 11:49:00 +00001181 debug_info->set_shared(*shared);
1182 debug_info->set_original_code(*original_code);
1183 debug_info->set_code(*code);
1184 debug_info->set_break_points(*break_points);
1185
1186 // Link debug info to function.
1187 shared->set_debug_info(*debug_info);
1188
1189 return debug_info;
1190}
1191#endif
1192
1193
1194Handle<JSObject> Factory::NewArgumentsObject(Handle<Object> callee,
1195 int length) {
Steve Block44f0eee2011-05-26 01:26:41 +01001196 CALL_HEAP_FUNCTION(
1197 isolate(),
1198 isolate()->heap()->AllocateArgumentsObject(*callee, length), JSObject);
Steve Blocka7e24c12009-10-30 11:49:00 +00001199}
1200
1201
1202Handle<JSFunction> Factory::CreateApiFunction(
1203 Handle<FunctionTemplateInfo> obj, ApiInstanceType instance_type) {
Steve Block44f0eee2011-05-26 01:26:41 +01001204 Handle<Code> code = isolate()->builtins()->HandleApiCall();
1205 Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi();
Steve Blocka7e24c12009-10-30 11:49:00 +00001206
1207 int internal_field_count = 0;
1208 if (!obj->instance_template()->IsUndefined()) {
1209 Handle<ObjectTemplateInfo> instance_template =
1210 Handle<ObjectTemplateInfo>(
1211 ObjectTemplateInfo::cast(obj->instance_template()));
1212 internal_field_count =
1213 Smi::cast(instance_template->internal_field_count())->value();
1214 }
1215
1216 int instance_size = kPointerSize * internal_field_count;
1217 InstanceType type = INVALID_TYPE;
1218 switch (instance_type) {
1219 case JavaScriptObject:
1220 type = JS_OBJECT_TYPE;
1221 instance_size += JSObject::kHeaderSize;
1222 break;
1223 case InnerGlobalObject:
1224 type = JS_GLOBAL_OBJECT_TYPE;
1225 instance_size += JSGlobalObject::kSize;
1226 break;
1227 case OuterGlobalObject:
1228 type = JS_GLOBAL_PROXY_TYPE;
1229 instance_size += JSGlobalProxy::kSize;
1230 break;
1231 default:
1232 break;
1233 }
1234 ASSERT(type != INVALID_TYPE);
1235
1236 Handle<JSFunction> result =
Steve Block44f0eee2011-05-26 01:26:41 +01001237 NewFunction(Factory::empty_symbol(),
1238 type,
1239 instance_size,
1240 code,
1241 true);
Steve Blocka7e24c12009-10-30 11:49:00 +00001242 // Set class name.
1243 Handle<Object> class_name = Handle<Object>(obj->class_name());
1244 if (class_name->IsString()) {
1245 result->shared()->set_instance_class_name(*class_name);
1246 result->shared()->set_name(*class_name);
1247 }
1248
1249 Handle<Map> map = Handle<Map>(result->initial_map());
1250
1251 // Mark as undetectable if needed.
1252 if (obj->undetectable()) {
1253 map->set_is_undetectable();
1254 }
1255
1256 // Mark as hidden for the __proto__ accessor if needed.
1257 if (obj->hidden_prototype()) {
1258 map->set_is_hidden_prototype();
1259 }
1260
1261 // Mark as needs_access_check if needed.
1262 if (obj->needs_access_check()) {
1263 map->set_is_access_check_needed(true);
1264 }
1265
1266 // Set interceptor information in the map.
1267 if (!obj->named_property_handler()->IsUndefined()) {
1268 map->set_has_named_interceptor();
1269 }
1270 if (!obj->indexed_property_handler()->IsUndefined()) {
1271 map->set_has_indexed_interceptor();
1272 }
1273
1274 // Set instance call-as-function information in the map.
1275 if (!obj->instance_call_handler()->IsUndefined()) {
1276 map->set_has_instance_call_handler();
1277 }
1278
1279 result->shared()->set_function_data(*obj);
Leon Clarkee46be812010-01-19 14:06:41 +00001280 result->shared()->set_construct_stub(*construct_stub);
Steve Blocka7e24c12009-10-30 11:49:00 +00001281 result->shared()->DontAdaptArguments();
1282
1283 // Recursively copy parent templates' accessors, 'data' may be modified.
1284 Handle<DescriptorArray> array =
1285 Handle<DescriptorArray>(map->instance_descriptors());
1286 while (true) {
1287 Handle<Object> props = Handle<Object>(obj->property_accessors());
1288 if (!props->IsUndefined()) {
Steve Block44f0eee2011-05-26 01:26:41 +01001289 array = CopyAppendCallbackDescriptors(array, props);
Steve Blocka7e24c12009-10-30 11:49:00 +00001290 }
1291 Handle<Object> parent = Handle<Object>(obj->parent_template());
1292 if (parent->IsUndefined()) break;
1293 obj = Handle<FunctionTemplateInfo>::cast(parent);
1294 }
1295 if (!array->IsEmpty()) {
1296 map->set_instance_descriptors(*array);
1297 }
1298
Steve Block6ded16b2010-05-10 14:33:55 +01001299 ASSERT(result->shared()->IsApiFunction());
Steve Blocka7e24c12009-10-30 11:49:00 +00001300 return result;
1301}
1302
1303
1304Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
Steve Block44f0eee2011-05-26 01:26:41 +01001305 CALL_HEAP_FUNCTION(isolate(),
1306 MapCache::Allocate(at_least_space_for), MapCache);
Steve Blocka7e24c12009-10-30 11:49:00 +00001307}
1308
1309
John Reck59135872010-11-02 12:39:01 -07001310MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context,
1311 FixedArray* keys,
1312 Map* map) {
1313 Object* result;
1314 { MaybeObject* maybe_result =
1315 MapCache::cast(context->map_cache())->Put(keys, map);
1316 if (!maybe_result->ToObject(&result)) return maybe_result;
1317 }
1318 context->set_map_cache(MapCache::cast(result));
Steve Blocka7e24c12009-10-30 11:49:00 +00001319 return result;
1320}
1321
1322
1323Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
1324 Handle<FixedArray> keys,
1325 Handle<Map> map) {
Steve Block44f0eee2011-05-26 01:26:41 +01001326 CALL_HEAP_FUNCTION(isolate(),
1327 UpdateMapCacheWith(*context, *keys, *map), MapCache);
Steve Blocka7e24c12009-10-30 11:49:00 +00001328}
1329
1330
1331Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context,
1332 Handle<FixedArray> keys) {
1333 if (context->map_cache()->IsUndefined()) {
1334 // Allocate the new map cache for the global context.
1335 Handle<MapCache> new_cache = NewMapCache(24);
1336 context->set_map_cache(*new_cache);
1337 }
1338 // Check to see whether there is a matching element in the cache.
1339 Handle<MapCache> cache =
1340 Handle<MapCache>(MapCache::cast(context->map_cache()));
1341 Handle<Object> result = Handle<Object>(cache->Lookup(*keys));
1342 if (result->IsMap()) return Handle<Map>::cast(result);
1343 // Create a new map and add it to the cache.
1344 Handle<Map> map =
1345 CopyMap(Handle<Map>(context->object_function()->initial_map()),
1346 keys->length());
1347 AddToMapCache(context, keys, map);
1348 return Handle<Map>(map);
1349}
1350
1351
1352void Factory::SetRegExpAtomData(Handle<JSRegExp> regexp,
1353 JSRegExp::Type type,
1354 Handle<String> source,
1355 JSRegExp::Flags flags,
1356 Handle<Object> data) {
1357 Handle<FixedArray> store = NewFixedArray(JSRegExp::kAtomDataSize);
1358
1359 store->set(JSRegExp::kTagIndex, Smi::FromInt(type));
1360 store->set(JSRegExp::kSourceIndex, *source);
1361 store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value()));
1362 store->set(JSRegExp::kAtomPatternIndex, *data);
1363 regexp->set_data(*store);
1364}
1365
1366void Factory::SetRegExpIrregexpData(Handle<JSRegExp> regexp,
1367 JSRegExp::Type type,
1368 Handle<String> source,
1369 JSRegExp::Flags flags,
1370 int capture_count) {
1371 Handle<FixedArray> store = NewFixedArray(JSRegExp::kIrregexpDataSize);
Ben Murdoch257744e2011-11-30 15:57:28 +00001372 Smi* uninitialized = Smi::FromInt(JSRegExp::kUninitializedValue);
Steve Blocka7e24c12009-10-30 11:49:00 +00001373 store->set(JSRegExp::kTagIndex, Smi::FromInt(type));
1374 store->set(JSRegExp::kSourceIndex, *source);
1375 store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value()));
Ben Murdoch257744e2011-11-30 15:57:28 +00001376 store->set(JSRegExp::kIrregexpASCIICodeIndex, uninitialized);
1377 store->set(JSRegExp::kIrregexpUC16CodeIndex, uninitialized);
1378 store->set(JSRegExp::kIrregexpASCIICodeSavedIndex, uninitialized);
1379 store->set(JSRegExp::kIrregexpUC16CodeSavedIndex, uninitialized);
Steve Blocka7e24c12009-10-30 11:49:00 +00001380 store->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(0));
1381 store->set(JSRegExp::kIrregexpCaptureCountIndex,
1382 Smi::FromInt(capture_count));
1383 regexp->set_data(*store);
1384}
1385
1386
1387
1388void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc,
1389 Handle<JSObject> instance,
1390 bool* pending_exception) {
1391 // Configure the instance by adding the properties specified by the
1392 // instance template.
1393 Handle<Object> instance_template = Handle<Object>(desc->instance_template());
1394 if (!instance_template->IsUndefined()) {
1395 Execution::ConfigureInstance(instance,
1396 instance_template,
1397 pending_exception);
1398 } else {
1399 *pending_exception = false;
1400 }
1401}
1402
1403
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001404Handle<Object> Factory::GlobalConstantFor(Handle<String> name) {
1405 Heap* h = isolate()->heap();
1406 if (name->Equals(h->undefined_symbol())) return undefined_value();
1407 if (name->Equals(h->nan_symbol())) return nan_value();
1408 if (name->Equals(h->infinity_symbol())) return infinity_value();
1409 return Handle<Object>::null();
1410}
1411
1412
1413Handle<Object> Factory::ToBoolean(bool value) {
1414 return Handle<Object>(value
1415 ? isolate()->heap()->true_value()
1416 : isolate()->heap()->false_value());
1417}
1418
1419
Steve Blocka7e24c12009-10-30 11:49:00 +00001420} } // namespace v8::internal