v8  3.14.5(node0.10.28)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
factory.cc
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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"
35 #include "objects.h"
36 #include "objects-visiting.h"
37 #include "platform.h"
38 #include "scopeinfo.h"
39 
40 namespace v8 {
41 namespace internal {
42 
43 
45  ASSERT(0 <= size);
47  isolate(),
48  isolate()->heap()->AllocateFixedArray(size, pretenure),
49  FixedArray);
50 }
51 
52 
54  PretenureFlag pretenure) {
55  ASSERT(0 <= size);
57  isolate(),
58  isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure),
59  FixedArray);
60 }
61 
62 
64  PretenureFlag pretenure) {
65  ASSERT(0 <= size);
67  isolate(),
68  isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure),
70 }
71 
72 
74  ASSERT(0 <= at_least_space_for);
75  CALL_HEAP_FUNCTION(isolate(),
76  StringDictionary::Allocate(at_least_space_for),
78 }
79 
80 
82  int at_least_space_for) {
83  ASSERT(0 <= at_least_space_for);
84  CALL_HEAP_FUNCTION(isolate(),
85  SeededNumberDictionary::Allocate(at_least_space_for),
87 }
88 
89 
91  int at_least_space_for) {
92  ASSERT(0 <= at_least_space_for);
93  CALL_HEAP_FUNCTION(isolate(),
94  UnseededNumberDictionary::Allocate(at_least_space_for),
96 }
97 
98 
100  ASSERT(0 <= at_least_space_for);
101  CALL_HEAP_FUNCTION(isolate(),
102  ObjectHashSet::Allocate(at_least_space_for),
103  ObjectHashSet);
104 }
105 
106 
108  ASSERT(0 <= at_least_space_for);
109  CALL_HEAP_FUNCTION(isolate(),
110  ObjectHashTable::Allocate(at_least_space_for),
112 }
113 
114 
116  int slack) {
117  ASSERT(0 <= number_of_descriptors);
118  CALL_HEAP_FUNCTION(isolate(),
119  DescriptorArray::Allocate(number_of_descriptors, slack),
121 }
122 
123 
125  int deopt_entry_count,
126  PretenureFlag pretenure) {
127  ASSERT(deopt_entry_count > 0);
128  CALL_HEAP_FUNCTION(isolate(),
129  DeoptimizationInputData::Allocate(deopt_entry_count,
130  pretenure),
132 }
133 
134 
136  int deopt_entry_count,
137  PretenureFlag pretenure) {
138  ASSERT(deopt_entry_count > 0);
139  CALL_HEAP_FUNCTION(isolate(),
140  DeoptimizationOutputData::Allocate(deopt_entry_count,
141  pretenure),
143 }
144 
145 
147  CALL_HEAP_FUNCTION(isolate(),
148  isolate()->heap()->AllocateAccessorPair(),
149  AccessorPair);
150 }
151 
152 
154  CALL_HEAP_FUNCTION(isolate(),
155  isolate()->heap()->AllocateTypeFeedbackInfo(),
157 }
158 
159 
160 // Symbols are created in the old generation (data space).
162  CALL_HEAP_FUNCTION(isolate(),
163  isolate()->heap()->LookupSymbol(string),
164  String);
165 }
166 
167 // Symbols are created in the old generation (data space).
169  CALL_HEAP_FUNCTION(isolate(),
170  isolate()->heap()->LookupSymbol(*string),
171  String);
172 }
173 
175  CALL_HEAP_FUNCTION(isolate(),
176  isolate()->heap()->LookupAsciiSymbol(string),
177  String);
178 }
179 
180 
182  int from,
183  int length) {
184  CALL_HEAP_FUNCTION(isolate(),
185  isolate()->heap()->LookupAsciiSymbol(string,
186  from,
187  length),
188  String);
189 }
190 
191 
193  CALL_HEAP_FUNCTION(isolate(),
194  isolate()->heap()->LookupTwoByteSymbol(string),
195  String);
196 }
197 
198 
200  PretenureFlag pretenure) {
202  isolate(),
203  isolate()->heap()->AllocateStringFromAscii(string, pretenure),
204  String);
205 }
206 
208  PretenureFlag pretenure) {
210  isolate(),
211  isolate()->heap()->AllocateStringFromUtf8(string, pretenure),
212  String);
213 }
214 
215 
217  PretenureFlag pretenure) {
219  isolate(),
220  isolate()->heap()->AllocateStringFromTwoByte(string, pretenure),
221  String);
222 }
223 
224 
226  PretenureFlag pretenure) {
228  isolate(),
229  isolate()->heap()->AllocateRawAsciiString(length, pretenure),
231 }
232 
233 
235  PretenureFlag pretenure) {
237  isolate(),
238  isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
240 }
241 
242 
244  Handle<String> second) {
245  CALL_HEAP_FUNCTION(isolate(),
246  isolate()->heap()->AllocateConsString(*first, *second),
247  String);
248 }
249 
250 
252  int begin,
253  int end) {
254  CALL_HEAP_FUNCTION(isolate(),
255  str->SubString(begin, end),
256  String);
257 }
258 
259 
261  int begin,
262  int end) {
263  ASSERT(begin > 0 || end < str->length());
264  CALL_HEAP_FUNCTION(isolate(),
265  isolate()->heap()->AllocateSubString(*str, begin, end),
266  String);
267 }
268 
269 
271  const ExternalAsciiString::Resource* resource) {
273  isolate(),
274  isolate()->heap()->AllocateExternalStringFromAscii(resource),
275  String);
276 }
277 
278 
280  const ExternalTwoByteString::Resource* resource) {
282  isolate(),
283  isolate()->heap()->AllocateExternalStringFromTwoByte(resource),
284  String);
285 }
286 
287 
290  isolate(),
291  isolate()->heap()->AllocateNativeContext(),
292  Context);
293 }
294 
295 
297  Handle<ScopeInfo> scope_info) {
299  isolate(),
300  isolate()->heap()->AllocateGlobalContext(*function, *scope_info),
301  Context);
302 }
303 
304 
307  isolate(),
308  isolate()->heap()->AllocateModuleContext(*scope_info),
309  Context);
310 }
311 
312 
314  Handle<JSFunction> function) {
316  isolate(),
317  isolate()->heap()->AllocateFunctionContext(length, *function),
318  Context);
319 }
320 
321 
323  Handle<Context> previous,
324  Handle<String> name,
325  Handle<Object> thrown_object) {
327  isolate(),
328  isolate()->heap()->AllocateCatchContext(*function,
329  *previous,
330  *name,
331  *thrown_object),
332  Context);
333 }
334 
335 
337  Handle<Context> previous,
338  Handle<JSObject> extension) {
340  isolate(),
341  isolate()->heap()->AllocateWithContext(*function, *previous, *extension),
342  Context);
343 }
344 
345 
347  Handle<Context> previous,
348  Handle<ScopeInfo> scope_info) {
350  isolate(),
351  isolate()->heap()->AllocateBlockContext(*function,
352  *previous,
353  *scope_info),
354  Context);
355 }
356 
357 
360  isolate(),
361  isolate()->heap()->AllocateStruct(type),
362  Struct);
363 }
364 
365 
367  Handle<AccessorInfo> info =
369  info->set_flag(0); // Must clear the flag, it was initialized as undefined.
370  return info;
371 }
372 
373 
375  // Generate id for this script.
376  int id;
377  Heap* heap = isolate()->heap();
378  if (heap->last_script_id()->IsUndefined()) {
379  // Script ids start from one.
380  id = 1;
381  } else {
382  // Increment id, wrap when positive smi is exhausted.
383  id = Smi::cast(heap->last_script_id())->value();
384  id++;
385  if (!Smi::IsValid(id)) {
386  id = 0;
387  }
388  }
389  heap->SetLastScriptId(Smi::FromInt(id));
390 
391  // Create and initialize script object.
392  Handle<Foreign> wrapper = NewForeign(0, TENURED);
394  script->set_source(*source);
395  script->set_name(heap->undefined_value());
396  script->set_id(heap->last_script_id());
397  script->set_line_offset(Smi::FromInt(0));
398  script->set_column_offset(Smi::FromInt(0));
399  script->set_data(heap->undefined_value());
400  script->set_context_data(heap->undefined_value());
401  script->set_type(Smi::FromInt(Script::TYPE_NORMAL));
402  script->set_compilation_type(Smi::FromInt(Script::COMPILATION_TYPE_HOST));
403  script->set_compilation_state(
405  script->set_wrapper(*wrapper);
406  script->set_line_ends(heap->undefined_value());
407  script->set_eval_from_shared(heap->undefined_value());
408  script->set_eval_from_instructions_offset(Smi::FromInt(0));
409 
410  return script;
411 }
412 
413 
415  CALL_HEAP_FUNCTION(isolate(),
416  isolate()->heap()->AllocateForeign(addr, pretenure),
417  Foreign);
418 }
419 
420 
422  return NewForeign((Address) desc, TENURED);
423 }
424 
425 
427  ASSERT(0 <= length);
429  isolate(),
430  isolate()->heap()->AllocateByteArray(length, pretenure),
431  ByteArray);
432 }
433 
434 
436  ExternalArrayType array_type,
437  void* external_pointer,
438  PretenureFlag pretenure) {
439  ASSERT(0 <= length);
441  isolate(),
442  isolate()->heap()->AllocateExternalArray(length,
443  array_type,
444  external_pointer,
445  pretenure),
446  ExternalArray);
447 }
448 
449 
451  Handle<Object> value) {
453  isolate(),
454  isolate()->heap()->AllocateJSGlobalPropertyCell(*value),
456 }
457 
458 
460  int instance_size,
461  ElementsKind elements_kind) {
463  isolate(),
464  isolate()->heap()->AllocateMap(type, instance_size, elements_kind),
465  Map);
466 }
467 
468 
471  isolate(),
472  isolate()->heap()->AllocateFunctionPrototype(*function),
473  JSObject);
474 }
475 
476 
479  isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map);
480 }
481 
482 
484  int extra_inobject_properties) {
486  // Check that we do not overflow the instance size when adding the
487  // extra inobject properties.
488  int instance_size_delta = extra_inobject_properties * kPointerSize;
489  int max_instance_size_delta =
490  JSObject::kMaxInstanceSize - copy->instance_size();
491  if (instance_size_delta > max_instance_size_delta) {
492  // If the instance size overflows, we allocate as many properties
493  // as we can as inobject properties.
494  instance_size_delta = max_instance_size_delta;
495  extra_inobject_properties = max_instance_size_delta >> kPointerSizeLog2;
496  }
497  // Adjust the map with the extra inobject properties.
498  int inobject_properties =
499  copy->inobject_properties() + extra_inobject_properties;
500  copy->set_inobject_properties(inobject_properties);
501  copy->set_unused_property_fields(inobject_properties);
502  copy->set_instance_size(copy->instance_size() + instance_size_delta);
503  copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
504  return copy;
505 }
506 
507 
509  CALL_HEAP_FUNCTION(isolate(), src->Copy(), Map);
510 }
511 
512 
514  Handle<JSObject> src,
515  ElementsKind elements_kind) {
516  Isolate* i = isolate();
518  src->GetElementsTransitionMap(i, elements_kind),
519  Map);
520 }
521 
522 
524  CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray);
525 }
526 
527 
529  Handle<FixedDoubleArray> array) {
530  CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedDoubleArray);
531 }
532 
533 
535  Handle<SharedFunctionInfo> function_info,
536  Handle<Map> function_map,
537  PretenureFlag pretenure) {
539  isolate(),
540  isolate()->heap()->AllocateFunction(*function_map,
541  *function_info,
542  isolate()->heap()->the_hole_value(),
543  pretenure),
544  JSFunction);
545 }
546 
547 
549  Handle<SharedFunctionInfo> function_info,
550  Handle<Context> context,
551  PretenureFlag pretenure) {
553  function_info,
554  function_info->is_classic_mode()
555  ? isolate()->function_map()
556  : isolate()->strict_mode_function_map(),
557  pretenure);
558 
559  if (function_info->ic_age() != isolate()->heap()->global_ic_age()) {
560  function_info->ResetForNewContext(isolate()->heap()->global_ic_age());
561  }
562 
563  result->set_context(*context);
564 
565  int index = function_info->SearchOptimizedCodeMap(context->native_context());
566  if (!function_info->bound() && index < 0) {
567  int number_of_literals = function_info->num_literals();
568  Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
569  if (number_of_literals > 0) {
570  // Store the native context in the literals array prefix. This
571  // context will be used when creating object, regexp and array
572  // literals in this function.
574  context->native_context());
575  }
576  result->set_literals(*literals);
577  }
578 
579  if (index > 0) {
580  // Caching of optimized code enabled and optimized code found.
581  function_info->InstallFromOptimizedCodeMap(*result, index);
582  return result;
583  }
584 
585  if (V8::UseCrankshaft() &&
586  FLAG_always_opt &&
587  result->is_compiled() &&
588  !function_info->is_toplevel() &&
589  function_info->allows_lazy_compilation() &&
590  !function_info->optimization_disabled()) {
591  result->MarkForLazyRecompilation();
592  }
593  return result;
594 }
595 
596 
598  PretenureFlag pretenure) {
600  isolate(),
601  isolate()->heap()->NumberFromDouble(value, pretenure), Object);
602 }
603 
604 
606  PretenureFlag pretenure) {
608  isolate(),
609  isolate()->heap()->NumberFromInt32(value, pretenure), Object);
610 }
611 
612 
614  PretenureFlag pretenure) {
616  isolate(),
617  isolate()->heap()->NumberFromUint32(value, pretenure), Object);
618 }
619 
620 
623  isolate(),
624  isolate()->heap()->AllocateJSObjectFromMap(
625  isolate()->heap()->neander_map()),
626  JSObject);
627 }
628 
629 
631  Vector< Handle<Object> > args) {
632  return NewError("MakeTypeError", type, args);
633 }
634 
635 
637  return NewError("$TypeError", message);
638 }
639 
640 
642  Vector< Handle<Object> > args) {
643  return NewError("MakeRangeError", type, args);
644 }
645 
646 
648  return NewError("$RangeError", message);
649 }
650 
651 
653  return NewError("MakeSyntaxError", type, args);
654 }
655 
656 
658  return NewError("$SyntaxError", message);
659 }
660 
661 
663  Vector< Handle<Object> > args) {
664  return NewError("MakeReferenceError", type, args);
665 }
666 
667 
669  return NewError("$ReferenceError", message);
670 }
671 
672 
673 Handle<Object> Factory::NewError(const char* maker, const char* type,
674  Vector< Handle<Object> > args) {
675  v8::HandleScope scope; // Instantiate a closeable HandleScope for EscapeFrom.
676  Handle<FixedArray> array = NewFixedArray(args.length());
677  for (int i = 0; i < args.length(); i++) {
678  array->set(i, *args[i]);
679  }
680  Handle<JSArray> object = NewJSArrayWithElements(array);
681  Handle<Object> result = NewError(maker, type, object);
682  return result.EscapeFrom(&scope);
683 }
684 
685 
687  Vector< Handle<Object> > args) {
688  return NewError("MakeEvalError", type, args);
689 }
690 
691 
693  Vector< Handle<Object> > args) {
694  return NewError("MakeError", type, args);
695 }
696 
697 
699  Handle<JSArray> args) {
700  const int kBufferSize = 1000;
701  char buffer[kBufferSize];
702  size_t space = kBufferSize;
703  char* p = &buffer[0];
704 
705  Vector<char> v(buffer, kBufferSize);
706  OS::StrNCpy(v, type, space);
707  space -= Min(space, strlen(type));
708  p = &buffer[kBufferSize] - space;
709 
710  for (unsigned i = 0; i < ARRAY_SIZE(args); i++) {
711  if (space > 0) {
712  *p++ = ' ';
713  space--;
714  if (space > 0) {
715  MaybeObject* maybe_arg = args->GetElement(i);
716  Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg));
717  const char* arg = *arg_str->ToCString();
718  Vector<char> v2(p, static_cast<int>(space));
719  OS::StrNCpy(v2, arg, space);
720  space -= Min(space, strlen(arg));
721  p = &buffer[kBufferSize] - space;
722  }
723  }
724  }
725  if (space > 0) {
726  *p = '\0';
727  } else {
728  buffer[kBufferSize - 1] = '\0';
729  }
730  Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED);
731  return error_string;
732 }
733 
734 
736  const char* type,
737  Handle<JSArray> args) {
738  Handle<String> make_str = LookupAsciiSymbol(maker);
739  Handle<Object> fun_obj(
740  isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str));
741  // If the builtins haven't been properly configured yet this error
742  // constructor may not have been defined. Bail out.
743  if (!fun_obj->IsJSFunction()) {
744  return EmergencyNewError(type, args);
745  }
747  Handle<Object> type_obj = LookupAsciiSymbol(type);
748  Handle<Object> argv[] = { type_obj, args };
749 
750  // Invoke the JavaScript factory method. If an exception is thrown while
751  // running the factory method, use the exception as the result.
752  bool caught_exception;
753  Handle<Object> result = Execution::TryCall(fun,
754  isolate()->js_builtins_object(),
755  ARRAY_SIZE(argv),
756  argv,
757  &caught_exception);
758  return result;
759 }
760 
761 
763  return NewError("$Error", message);
764 }
765 
766 
767 Handle<Object> Factory::NewError(const char* constructor,
769  Handle<String> constr = LookupAsciiSymbol(constructor);
771  JSFunction::cast(isolate()->js_builtins_object()->
772  GetPropertyNoExceptionThrown(*constr)));
773  Handle<Object> argv[] = { message };
774 
775  // Invoke the JavaScript factory method. If an exception is thrown while
776  // running the factory method, use the exception as the result.
777  bool caught_exception;
778  Handle<Object> result = Execution::TryCall(fun,
779  isolate()->js_builtins_object(),
780  ARRAY_SIZE(argv),
781  argv,
782  &caught_exception);
783  return result;
784 }
785 
786 
788  InstanceType type,
789  int instance_size,
791  bool force_initial_map) {
792  // Allocate the function
793  Handle<JSFunction> function = NewFunction(name, the_hole_value());
794 
795  // Set up the code pointer in both the shared function info and in
796  // the function itself.
797  function->shared()->set_code(*code);
798  function->set_code(*code);
799 
800  if (force_initial_map ||
801  type != JS_OBJECT_TYPE ||
802  instance_size != JSObject::kHeaderSize) {
803  Handle<Map> initial_map = NewMap(type, instance_size);
804  Handle<JSObject> prototype = NewFunctionPrototype(function);
805  initial_map->set_prototype(*prototype);
806  function->set_initial_map(*initial_map);
807  initial_map->set_constructor(*function);
808  } else {
809  ASSERT(!function->has_initial_map());
810  ASSERT(!function->has_prototype());
811  }
812 
813  return function;
814 }
815 
816 
818  InstanceType type,
819  int instance_size,
820  Handle<JSObject> prototype,
822  bool force_initial_map) {
823  // Allocate the function.
824  Handle<JSFunction> function = NewFunction(name, prototype);
825 
826  // Set up the code pointer in both the shared function info and in
827  // the function itself.
828  function->shared()->set_code(*code);
829  function->set_code(*code);
830 
831  if (force_initial_map ||
832  type != JS_OBJECT_TYPE ||
833  instance_size != JSObject::kHeaderSize) {
834  Handle<Map> initial_map = NewMap(type,
835  instance_size,
837  function->set_initial_map(*initial_map);
838  initial_map->set_constructor(*function);
839  }
840 
841  // Set function.prototype and give the prototype a constructor
842  // property that refers to the function.
843  SetPrototypeProperty(function, prototype);
844  // Currently safe because it is only invoked from Genesis.
845  CHECK_NOT_EMPTY_HANDLE(isolate(),
847  prototype, constructor_symbol(),
848  function, DONT_ENUM));
849  return function;
850 }
851 
852 
854  Handle<Code> code) {
856  CLASSIC_MODE);
857  function->shared()->set_code(*code);
858  function->set_code(*code);
859  ASSERT(!function->has_initial_map());
860  ASSERT(!function->has_prototype());
861  return function;
862 }
863 
864 
867  isolate(),
868  isolate()->heap()->AllocateScopeInfo(length),
869  ScopeInfo);
870 }
871 
872 
875  Handle<Object> self_ref,
876  bool immovable) {
877  CALL_HEAP_FUNCTION(isolate(),
878  isolate()->heap()->CreateCode(
879  desc, flags, self_ref, immovable),
880  Code);
881 }
882 
883 
885  CALL_HEAP_FUNCTION(isolate(),
886  isolate()->heap()->CopyCode(*code),
887  Code);
888 }
889 
890 
892  CALL_HEAP_FUNCTION(isolate(),
893  isolate()->heap()->CopyCode(*code, reloc_info),
894  Code);
895 }
896 
897 
899  CALL_HEAP_FUNCTION(isolate(),
900  isolate()->heap()->LookupSymbol(*value), String);
901 }
902 
903 
905  PretenureFlag pretenure) {
907  isolate(),
908  isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
909 }
910 
911 
913  Handle<ScopeInfo> scope_info) {
915  isolate(),
916  isolate()->heap()->AllocateJSModule(*context, *scope_info), JSModule);
917 }
918 
919 
921  Handle<JSFunction> constructor) {
922  CALL_HEAP_FUNCTION(isolate(),
923  isolate()->heap()->AllocateGlobalObject(*constructor),
924  GlobalObject);
925 }
926 
927 
928 
931  isolate(),
932  isolate()->heap()->AllocateJSObjectFromMap(*map, NOT_TENURED),
933  JSObject);
934 }
935 
936 
938  ElementsKind elements_kind,
939  PretenureFlag pretenure) {
940  CALL_HEAP_FUNCTION(isolate(),
941  isolate()->heap()->AllocateJSArrayAndStorage(
942  elements_kind,
943  0,
944  capacity,
946  pretenure),
947  JSArray);
948 }
949 
950 
952  ElementsKind elements_kind,
953  PretenureFlag pretenure) {
955  isolate(),
956  isolate()->heap()->AllocateJSArrayWithElements(*elements,
957  elements_kind,
958  pretenure),
959  JSArray);
960 }
961 
962 
964  int capacity,
965  int length) {
966  ElementsAccessor* accessor = array->GetElementsAccessor();
968  isolate(),
969  accessor->SetCapacityAndLength(*array, capacity, length));
970 }
971 
972 
974  Handle<FixedArrayBase> elements) {
976  isolate(),
977  array->SetContent(*elements));
978 }
979 
980 
983  isolate(),
984  array->EnsureCanContainHeapObjectElements());
985 }
986 
987 
989  Handle<FixedArrayBase> elements,
990  uint32_t length,
991  EnsureElementsMode mode) {
993  isolate(),
994  array->EnsureCanContainElements(*elements, length, mode));
995 }
996 
997 
999  Handle<Object> prototype) {
1001  isolate(),
1002  isolate()->heap()->AllocateJSProxy(*handler, *prototype),
1003  JSProxy);
1004 }
1005 
1006 
1009  isolate(),
1010  isolate()->heap()->ReinitializeJSReceiver(
1012 }
1013 
1014 
1017  isolate(),
1018  isolate()->heap()->ReinitializeJSReceiver(
1019  *object, JS_FUNCTION_TYPE, JSFunction::kSize));
1020 }
1021 
1022 
1025  isolate(),
1026  object->SetIdentityHash(hash, ALLOW_CREATION));
1027 }
1028 
1029 
1031  Handle<String> name,
1032  int number_of_literals,
1034  Handle<ScopeInfo> scope_info) {
1036  shared->set_code(*code);
1037  shared->set_scope_info(*scope_info);
1038  int literals_array_size = number_of_literals;
1039  // If the function contains object, regexp or array literals,
1040  // allocate extra space for a literals array prefix containing the
1041  // context.
1042  if (number_of_literals > 0) {
1043  literals_array_size += JSFunction::kLiteralsPrefixSize;
1044  }
1045  shared->set_num_literals(literals_array_size);
1046  return shared;
1047 }
1048 
1049 
1051  Handle<String> type,
1052  Handle<JSArray> arguments,
1053  int start_position,
1054  int end_position,
1055  Handle<Object> script,
1056  Handle<Object> stack_trace,
1057  Handle<Object> stack_frames) {
1058  CALL_HEAP_FUNCTION(isolate(),
1059  isolate()->heap()->AllocateJSMessageObject(*type,
1060  *arguments,
1061  start_position,
1062  end_position,
1063  *script,
1064  *stack_trace,
1065  *stack_frames),
1066  JSMessageObject);
1067 }
1068 
1070  CALL_HEAP_FUNCTION(isolate(),
1071  isolate()->heap()->AllocateSharedFunctionInfo(*name),
1073 }
1074 
1075 
1077  CALL_HEAP_FUNCTION(isolate(),
1078  isolate()->heap()->NumberToString(*number), String);
1079 }
1080 
1081 
1083  CALL_HEAP_FUNCTION(isolate(),
1084  isolate()->heap()->Uint32ToString(value), String);
1085 }
1086 
1087 
1089  Handle<SeededNumberDictionary> dictionary,
1090  uint32_t key,
1091  Handle<Object> value) {
1092  CALL_HEAP_FUNCTION(isolate(),
1093  dictionary->AtNumberPut(key, *value),
1095 }
1096 
1097 
1100  uint32_t key,
1101  Handle<Object> value) {
1102  CALL_HEAP_FUNCTION(isolate(),
1103  dictionary->AtNumberPut(key, *value),
1105 }
1106 
1107 
1108 Handle<JSFunction> Factory::NewFunctionHelper(Handle<String> name,
1109  Handle<Object> prototype) {
1110  Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
1112  isolate(),
1113  isolate()->heap()->AllocateFunction(*isolate()->function_map(),
1114  *function_share,
1115  *prototype),
1116  JSFunction);
1117 }
1118 
1119 
1121  Handle<Object> prototype) {
1122  Handle<JSFunction> fun = NewFunctionHelper(name, prototype);
1123  fun->set_context(isolate()->context()->native_context());
1124  return fun;
1125 }
1126 
1127 
1128 Handle<JSFunction> Factory::NewFunctionWithoutPrototypeHelper(
1129  Handle<String> name,
1130  LanguageMode language_mode) {
1131  Handle<SharedFunctionInfo> function_share = NewSharedFunctionInfo(name);
1132  Handle<Map> map = (language_mode == CLASSIC_MODE)
1133  ? isolate()->function_without_prototype_map()
1134  : isolate()->strict_mode_function_without_prototype_map();
1135  CALL_HEAP_FUNCTION(isolate(),
1136  isolate()->heap()->AllocateFunction(
1137  *map,
1138  *function_share,
1139  *the_hole_value()),
1140  JSFunction);
1141 }
1142 
1143 
1145  Handle<String> name,
1146  LanguageMode language_mode) {
1147  Handle<JSFunction> fun =
1148  NewFunctionWithoutPrototypeHelper(name, language_mode);
1149  fun->set_context(isolate()->context()->native_context());
1150  return fun;
1151 }
1152 
1153 
1155  CALL_HEAP_FUNCTION(isolate(), object->ToObject(), Object);
1156 }
1157 
1158 
1160  Handle<Context> native_context) {
1161  CALL_HEAP_FUNCTION(isolate(), object->ToObject(*native_context), Object);
1162 }
1163 
1164 
1165 #ifdef ENABLE_DEBUGGER_SUPPORT
1166 Handle<DebugInfo> Factory::NewDebugInfo(Handle<SharedFunctionInfo> shared) {
1167  // Get the original code of the function.
1168  Handle<Code> code(shared->code());
1169 
1170  // Create a copy of the code before allocating the debug info object to avoid
1171  // allocation while setting up the debug info object.
1172  Handle<Code> original_code(*Factory::CopyCode(code));
1173 
1174  // Allocate initial fixed array for active break points before allocating the
1175  // debug info object to avoid allocation while setting up the debug info
1176  // object.
1177  Handle<FixedArray> break_points(
1178  NewFixedArray(Debug::kEstimatedNofBreakPointsInFunction));
1179 
1180  // Create and set up the debug info object. Debug info contains function, a
1181  // copy of the original code, the executing code and initial fixed array for
1182  // active break points.
1183  Handle<DebugInfo> debug_info =
1185  debug_info->set_shared(*shared);
1186  debug_info->set_original_code(*original_code);
1187  debug_info->set_code(*code);
1188  debug_info->set_break_points(*break_points);
1189 
1190  // Link debug info to function.
1191  shared->set_debug_info(*debug_info);
1192 
1193  return debug_info;
1194 }
1195 #endif
1196 
1197 
1199  int length) {
1201  isolate(),
1202  isolate()->heap()->AllocateArgumentsObject(*callee, length), JSObject);
1203 }
1204 
1205 
1207  Handle<FunctionTemplateInfo> obj, ApiInstanceType instance_type) {
1208  Handle<Code> code = isolate()->builtins()->HandleApiCall();
1209  Handle<Code> construct_stub = isolate()->builtins()->JSConstructStubApi();
1210 
1211  int internal_field_count = 0;
1212  if (!obj->instance_template()->IsUndefined()) {
1215  ObjectTemplateInfo::cast(obj->instance_template()));
1216  internal_field_count =
1217  Smi::cast(instance_template->internal_field_count())->value();
1218  }
1219 
1220  int instance_size = kPointerSize * internal_field_count;
1221  InstanceType type = INVALID_TYPE;
1222  switch (instance_type) {
1223  case JavaScriptObject:
1224  type = JS_OBJECT_TYPE;
1225  instance_size += JSObject::kHeaderSize;
1226  break;
1227  case InnerGlobalObject:
1228  type = JS_GLOBAL_OBJECT_TYPE;
1229  instance_size += JSGlobalObject::kSize;
1230  break;
1231  case OuterGlobalObject:
1232  type = JS_GLOBAL_PROXY_TYPE;
1233  instance_size += JSGlobalProxy::kSize;
1234  break;
1235  default:
1236  break;
1237  }
1238  ASSERT(type != INVALID_TYPE);
1239 
1240  Handle<JSFunction> result =
1241  NewFunction(Factory::empty_symbol(),
1242  type,
1243  instance_size,
1244  code,
1245  true);
1246  // Set class name.
1247  Handle<Object> class_name = Handle<Object>(obj->class_name());
1248  if (class_name->IsString()) {
1249  result->shared()->set_instance_class_name(*class_name);
1250  result->shared()->set_name(*class_name);
1251  }
1252 
1253  Handle<Map> map = Handle<Map>(result->initial_map());
1254 
1255  // Mark as undetectable if needed.
1256  if (obj->undetectable()) {
1257  map->set_is_undetectable();
1258  }
1259 
1260  // Mark as hidden for the __proto__ accessor if needed.
1261  if (obj->hidden_prototype()) {
1262  map->set_is_hidden_prototype();
1263  }
1264 
1265  // Mark as needs_access_check if needed.
1266  if (obj->needs_access_check()) {
1267  map->set_is_access_check_needed(true);
1268  }
1269 
1270  // Set interceptor information in the map.
1271  if (!obj->named_property_handler()->IsUndefined()) {
1272  map->set_has_named_interceptor();
1273  }
1274  if (!obj->indexed_property_handler()->IsUndefined()) {
1275  map->set_has_indexed_interceptor();
1276  }
1277 
1278  // Set instance call-as-function information in the map.
1279  if (!obj->instance_call_handler()->IsUndefined()) {
1280  map->set_has_instance_call_handler();
1281  }
1282 
1283  result->shared()->set_function_data(*obj);
1284  result->shared()->set_construct_stub(*construct_stub);
1285  result->shared()->DontAdaptArguments();
1286 
1287  // Recursively copy parent templates' accessors, 'data' may be modified.
1288  int max_number_of_additional_properties = 0;
1289  FunctionTemplateInfo* info = *obj;
1290  while (true) {
1291  Object* props = info->property_accessors();
1292  if (!props->IsUndefined()) {
1293  Handle<Object> props_handle(props);
1294  NeanderArray props_array(props_handle);
1295  max_number_of_additional_properties += props_array.length();
1296  }
1297  Object* parent = info->parent_template();
1298  if (parent->IsUndefined()) break;
1299  info = FunctionTemplateInfo::cast(parent);
1300  }
1301 
1302  Map::EnsureDescriptorSlack(map, max_number_of_additional_properties);
1303 
1304  while (true) {
1305  Handle<Object> props = Handle<Object>(obj->property_accessors());
1306  if (!props->IsUndefined()) {
1307  Map::AppendCallbackDescriptors(map, props);
1308  }
1309  Handle<Object> parent = Handle<Object>(obj->parent_template());
1310  if (parent->IsUndefined()) break;
1311  obj = Handle<FunctionTemplateInfo>::cast(parent);
1312  }
1313 
1314  ASSERT(result->shared()->IsApiFunction());
1315  return result;
1316 }
1317 
1318 
1319 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
1320  CALL_HEAP_FUNCTION(isolate(),
1321  MapCache::Allocate(at_least_space_for), MapCache);
1322 }
1323 
1324 
1325 MUST_USE_RESULT static MaybeObject* UpdateMapCacheWith(Context* context,
1326  FixedArray* keys,
1327  Map* map) {
1328  Object* result;
1329  { MaybeObject* maybe_result =
1330  MapCache::cast(context->map_cache())->Put(keys, map);
1331  if (!maybe_result->ToObject(&result)) return maybe_result;
1332  }
1333  context->set_map_cache(MapCache::cast(result));
1334  return result;
1335 }
1336 
1337 
1338 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
1339  Handle<FixedArray> keys,
1340  Handle<Map> map) {
1341  CALL_HEAP_FUNCTION(isolate(),
1342  UpdateMapCacheWith(*context, *keys, *map), MapCache);
1343 }
1344 
1345 
1347  Handle<FixedArray> keys) {
1348  if (context->map_cache()->IsUndefined()) {
1349  // Allocate the new map cache for the native context.
1350  Handle<MapCache> new_cache = NewMapCache(24);
1351  context->set_map_cache(*new_cache);
1352  }
1353  // Check to see whether there is a matching element in the cache.
1354  Handle<MapCache> cache =
1355  Handle<MapCache>(MapCache::cast(context->map_cache()));
1356  Handle<Object> result = Handle<Object>(cache->Lookup(*keys));
1357  if (result->IsMap()) return Handle<Map>::cast(result);
1358  // Create a new map and add it to the cache.
1359  Handle<Map> map =
1360  CopyMap(Handle<Map>(context->object_function()->initial_map()),
1361  keys->length());
1362  AddToMapCache(context, keys, map);
1363  return Handle<Map>(map);
1364 }
1365 
1366 
1368  JSRegExp::Type type,
1369  Handle<String> source,
1371  Handle<Object> data) {
1373 
1374  store->set(JSRegExp::kTagIndex, Smi::FromInt(type));
1375  store->set(JSRegExp::kSourceIndex, *source);
1376  store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value()));
1377  store->set(JSRegExp::kAtomPatternIndex, *data);
1378  regexp->set_data(*store);
1379 }
1380 
1382  JSRegExp::Type type,
1383  Handle<String> source,
1385  int capture_count) {
1388  store->set(JSRegExp::kTagIndex, Smi::FromInt(type));
1389  store->set(JSRegExp::kSourceIndex, *source);
1390  store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value()));
1391  store->set(JSRegExp::kIrregexpASCIICodeIndex, uninitialized);
1392  store->set(JSRegExp::kIrregexpUC16CodeIndex, uninitialized);
1393  store->set(JSRegExp::kIrregexpASCIICodeSavedIndex, uninitialized);
1394  store->set(JSRegExp::kIrregexpUC16CodeSavedIndex, uninitialized);
1397  Smi::FromInt(capture_count));
1398  regexp->set_data(*store);
1399 }
1400 
1401 
1402 
1404  Handle<JSObject> instance,
1405  bool* pending_exception) {
1406  // Configure the instance by adding the properties specified by the
1407  // instance template.
1408  Handle<Object> instance_template = Handle<Object>(desc->instance_template());
1409  if (!instance_template->IsUndefined()) {
1411  instance_template,
1412  pending_exception);
1413  } else {
1414  *pending_exception = false;
1415  }
1416 }
1417 
1418 
1420  Heap* h = isolate()->heap();
1421  if (name->Equals(h->undefined_symbol())) return undefined_value();
1422  if (name->Equals(h->nan_symbol())) return nan_value();
1423  if (name->Equals(h->infinity_symbol())) return infinity_value();
1424  return Handle<Object>::null();
1425 }
1426 
1427 
1429  return Handle<Object>(value
1430  ? isolate()->heap()->true_value()
1431  : isolate()->heap()->false_value());
1432 }
1433 
1434 
1435 } } // namespace v8::internal
byte * Address
Definition: globals.h:157
#define CHECK_NOT_EMPTY_HANDLE(isolate, call)
Definition: isolate.h:128
Handle< JSObject > NewFunctionPrototype(Handle< JSFunction > function)
Definition: factory.cc:469
Handle< JSObject > NewJSObject(Handle< JSFunction > constructor, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:904
Handle< String > NewExternalStringFromAscii(const ExternalAsciiString::Resource *resource)
Definition: factory.cc:270
static const int kIrregexpMaxRegisterCountIndex
Definition: objects.h:6657
Handle< Context > NewModuleContext(Handle< ScopeInfo > scope_info)
Definition: factory.cc:305
Handle< JSFunction > NewFunctionFromSharedFunctionInfo(Handle< SharedFunctionInfo > function_info, Handle< Context > context, PretenureFlag pretenure=TENURED)
Definition: factory.cc:548
static Handle< Object > TryCall(Handle< JSFunction > func, Handle< Object > receiver, int argc, Handle< Object > argv[], bool *caught_exception)
Definition: execution.cc:192
Handle< String > SymbolFromString(Handle< String > value)
Definition: factory.cc:898
virtual MUST_USE_RESULT MaybeObject * SetCapacityAndLength(JSArray *array, int capacity, int length)=0
static MapCache * cast(Object *obj)
static bool UseCrankshaft()
Definition: v8.h:86
Handle< DescriptorArray > NewDescriptorArray(int number_of_descriptors, int slack=0)
Definition: factory.cc:115
Handle< FixedArray > NewFixedArrayWithHoles(int size, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:53
static Smi * FromInt(int value)
Definition: objects-inl.h:981
Handle< String > NewSubString(Handle< String > str, int begin, int end)
Definition: factory.cc:251
Handle< Script > NewScript(Handle< String > source)
Definition: factory.cc:374
Handle< SeqAsciiString > NewRawAsciiString(int length, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:225
Handle< ObjectHashTable > NewObjectHashTable(int at_least_space_for)
Definition: factory.cc:107
Handle< JSFunction > BaseNewFunctionFromSharedFunctionInfo(Handle< SharedFunctionInfo > function_info, Handle< Map > function_map, PretenureFlag pretenure)
Definition: factory.cc:534
static ObjectTemplateInfo * cast(Object *obj)
Handle< JSArray > NewJSArray(int capacity, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:937
static Handle< T > cast(Handle< S > that)
Definition: handles.h:81
Handle< Context > NewCatchContext(Handle< JSFunction > function, Handle< Context > previous, Handle< String > name, Handle< Object > thrown_object)
Definition: factory.cc:322
static const int kIrregexpDataSize
Definition: objects.h:6661
Builtins * builtins()
Definition: isolate.h:924
int int32_t
Definition: unicode.cc:47
Handle< Context > NewFunctionContext(int length, Handle< JSFunction > function)
Definition: factory.cc:313
Handle< AccessorInfo > NewAccessorInfo()
Definition: factory.cc:366
static const int kSize
Definition: objects.h:6235
int length()
Definition: api.cc:857
void SetPrototypeProperty(Handle< JSFunction > func, Handle< JSObject > value)
Definition: handles.cc:176
static const int kIrregexpASCIICodeIndex
Definition: objects.h:6642
static const int kIrregexpUC16CodeIndex
Definition: objects.h:6646
#define ASSERT(condition)
Definition: checks.h:270
static const int kIrregexpASCIICodeSavedIndex
Definition: objects.h:6650
static void AppendCallbackDescriptors(Handle< Map > map, Handle< Object > descriptors)
Definition: objects.cc:2187
Handle< JSFunction > NewFunctionWithPrototype(Handle< String > name, InstanceType type, int instance_size, Handle< JSObject > prototype, Handle< Code > code, bool force_initial_map)
Definition: factory.cc:817
const int kPointerSizeLog2
Definition: globals.h:232
ExternalArrayType
Definition: v8.h:1431
#define CALL_HEAP_FUNCTION_VOID(ISOLATE, FUNCTION_CALL)
Definition: heap-inl.h:565
static MUST_USE_RESULT MaybeObject * Allocate(int deopt_entry_count, PretenureFlag pretenure)
Definition: objects.cc:6156
static void ConfigureInstance(Handle< Object > instance, Handle< Object > data, bool *exc)
Definition: execution.cc:777
Handle< SharedFunctionInfo > NewSharedFunctionInfo(Handle< String > name, int number_of_literals, Handle< Code > code, Handle< ScopeInfo > scope_info)
Definition: factory.cc:1030
static const int kSourceIndex
Definition: objects.h:6629
kPropertyAccessorsOffset kNamedPropertyHandlerOffset instance_template
Definition: objects-inl.h:3860
int global_ic_age()
Definition: heap.h:1634
Handle< Object > NewNumber(double value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:597
Handle< JSObject > NewArgumentsObject(Handle< Object > callee, int length)
Definition: factory.cc:1198
Handle< Code > CopyCode(Handle< Code > code)
Definition: factory.cc:884
Handle< String > NumberToString(Handle< Object > number)
Definition: factory.cc:1076
void EnsureCanContainHeapObjectElements(Handle< JSArray > array)
Definition: factory.cc:981
Handle< String > LookupAsciiSymbol(Vector< const char > str)
Definition: factory.cc:174
Handle< JSMessageObject > NewJSMessageObject(Handle< String > type, Handle< JSArray > arguments, int start_position, int end_position, Handle< Object > script, Handle< Object > stack_trace, Handle< Object > stack_frames)
Definition: factory.cc:1050
Handle< Object > NewSyntaxError(const char *type, Handle< JSArray > args)
Definition: factory.cc:652
static Smi * cast(Object *object)
Handle< String > EmergencyNewError(const char *type, Handle< JSArray > args)
Definition: factory.cc:698
Handle< SeededNumberDictionary > DictionaryAtNumberPut(Handle< SeededNumberDictionary >, uint32_t key, Handle< Object > value)
Definition: factory.cc:1088
Handle< Map > GetElementsTransitionMap(Handle< JSObject > object, ElementsKind elements_kind)
Definition: factory.cc:513
Handle< String > NewStringFromUtf8(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:207
Handle< Object > NewRangeError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:641
void ConfigureInstance(Handle< FunctionTemplateInfo > desc, Handle< JSObject > instance, bool *pending_exception)
Definition: factory.cc:1403
static const int kLiteralNativeContextIndex
Definition: objects.h:6195
Handle< StringDictionary > NewStringDictionary(int at_least_space_for)
Definition: factory.cc:73
Handle< Map > CopyWithPreallocatedFieldDescriptors(Handle< Map > map)
Definition: factory.cc:477
Handle< Map > CopyMap(Handle< Map > map, int extra_inobject_props)
Definition: factory.cc:483
static const int kIrregexpUC16CodeSavedIndex
Definition: objects.h:6653
Handle< JSFunction > NewFunction(Handle< String > name, Handle< Object > prototype)
Definition: factory.cc:1120
Handle< SeqTwoByteString > NewRawTwoByteString(int length, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:234
void SetLastScriptId(Object *last_script_id)
Definition: heap-inl.h:498
#define MUST_USE_RESULT
Definition: globals.h:346
Handle< JSObject > NewNeanderObject()
Definition: factory.cc:621
Handle< ScopeInfo > NewScopeInfo(int length)
Definition: factory.cc:865
static bool IsValid(intptr_t value)
Definition: objects-inl.h:1059
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
Definition: heap-inl.h:558
void SetRegExpAtomData(Handle< JSRegExp > regexp, JSRegExp::Type type, Handle< String > source, JSRegExp::Flags flags, Handle< Object > match_pattern)
Definition: factory.cc:1367
void SetElementsCapacityAndLength(Handle< JSArray > array, int capacity, int length)
Definition: factory.cc:963
const int kPointerSize
Definition: globals.h:220
Handle< Object > ToBoolean(bool value)
Definition: factory.cc:1428
static const int kMaxInstanceSize
Definition: objects.h:2164
Handle< Object > GlobalConstantFor(Handle< String > name)
Definition: factory.cc:1419
Handle< String > LookupSymbol(Vector< const char > str)
Definition: factory.cc:161
Handle< JSObject > NewJSObjectFromMap(Handle< Map > map)
Definition: factory.cc:929
Handle< String > NewStringFromTwoByte(Vector< const uc16 > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:216
Handle< ExternalArray > NewExternalArray(int length, ExternalArrayType array_type, void *external_pointer, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:435
static Handle< Object > SetLocalPropertyIgnoreAttributes(Handle< JSObject > object, Handle< String > key, Handle< Object > value, PropertyAttributes attributes)
Definition: objects.cc:2952
Handle< ByteArray > NewByteArray(int length, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:426
static FunctionTemplateInfo * cast(Object *obj)
Handle< FixedDoubleArray > NewFixedDoubleArray(int size, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:63
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:44
static void EnsureDescriptorSlack(Handle< Map > map, int slack)
Definition: objects.cc:2170
Handle< GlobalObject > NewGlobalObject(Handle< JSFunction > constructor)
Definition: factory.cc:920
static const int kIrregexpCaptureCountIndex
Definition: objects.h:6659
Handle< Object > ToObject(Handle< Object > object)
Definition: factory.cc:1154
Handle< Context > NewBlockContext(Handle< JSFunction > function, Handle< Context > previous, Handle< ScopeInfo > scope_info)
Definition: factory.cc:346
static MUST_USE_RESULT MaybeObject * Allocate(int at_least_space_for)
Handle< FixedArray > CopyFixedArray(Handle< FixedArray > array)
Definition: factory.cc:523
Vector< const char > CStrVector(const char *data)
Definition: utils.h:526
void SetContent(Handle< JSArray > array, Handle< FixedArrayBase > elements)
Definition: factory.cc:973
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:951
Handle< Object > NewNumberFromInt(int32_t value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:605
Handle< String > NewProperSubString(Handle< String > str, int begin, int end)
Definition: factory.cc:260
Handle< DeoptimizationInputData > NewDeoptimizationInputData(int deopt_entry_count, PretenureFlag pretenure)
Definition: factory.cc:124
Handle< JSProxy > NewJSProxy(Handle< Object > handler, Handle< Object > prototype)
Definition: factory.cc:998
Handle< JSFunction > NewFunctionWithoutPrototype(Handle< String > name, LanguageMode language_mode)
Definition: factory.cc:1144
Handle< DeoptimizationOutputData > NewDeoptimizationOutputData(int deopt_entry_count, PretenureFlag pretenure)
Definition: factory.cc:135
Handle< String > NewStringFromAscii(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:199
static const int kAtomDataSize
Definition: objects.h:6637
Handle< String > NewExternalStringFromTwoByte(const ExternalTwoByteString::Resource *resource)
Definition: factory.cc:279
Handle< TypeFeedbackInfo > NewTypeFeedbackInfo()
Definition: factory.cc:153
Handle< Object > NewReferenceError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:662
Handle< JSFunction > CreateApiFunction(Handle< FunctionTemplateInfo > data, ApiInstanceType type=JavaScriptObject)
Definition: factory.cc:1206
static const int kAtomPatternIndex
Definition: objects.h:6635
void EnsureCanContainElements(Handle< JSArray > array, Handle< FixedArrayBase > elements, uint32_t length, EnsureElementsMode mode)
Definition: factory.cc:988
ElementsKind GetInitialFastElementsKind()
void BecomeJSObject(Handle< JSReceiver > object)
Definition: factory.cc:1007
Handle< Object > NewTypeError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:630
Handle< JSModule > NewJSModule(Handle< Context > context, Handle< ScopeInfo > scope_info)
Definition: factory.cc:912
Handle< T > EscapeFrom(v8::HandleScope *scope)
Definition: api.h:246
static Handle< T > null()
Definition: handles.h:86
Handle< Context > NewGlobalContext(Handle< JSFunction > function, Handle< ScopeInfo > scope_info)
Definition: factory.cc:296
static MUST_USE_RESULT MaybeObject * Allocate(int number_of_descriptors, int slack=0)
Definition: objects.cc:6032
Handle< Map > ObjectLiteralMapFromCache(Handle< Context > context, Handle< FixedArray > keys)
Definition: factory.cc:1346
Handle< Foreign > NewForeign(Address addr, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:414
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property keys(0 means random)" "(with snapshots this option cannot override the baked-in seed)") DEFINE_bool(preemption
void SetIdentityHash(Handle< JSObject > object, Smi *hash)
Definition: factory.cc:1023
Handle< String > Uint32ToString(uint32_t value)
Definition: factory.cc:1082
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
Definition: flags.cc:495
static void StrNCpy(Vector< char > dest, const char *src, size_t n)
static const int kHeaderSize
Definition: objects.h:2173
Handle< FixedDoubleArray > CopyFixedDoubleArray(Handle< FixedDoubleArray > array)
Definition: factory.cc:528
static const int kFlagsIndex
Definition: objects.h:6630
static VisitorId GetVisitorId(int instance_type, int instance_size)
Handle< String > LookupTwoByteSymbol(Vector< const uc16 > str)
Definition: factory.cc:192
static const int kSize
Definition: objects.h:6191
Handle< Context > NewWithContext(Handle< JSFunction > function, Handle< Context > previous, Handle< JSObject > extension)
Definition: factory.cc:336
Handle< Code > NewCode(const CodeDesc &desc, Code::Flags flags, Handle< Object > self_reference, bool immovable=false)
Definition: factory.cc:873
Handle< Struct > NewStruct(InstanceType type)
Definition: factory.cc:358
static const int kTagIndex
Definition: objects.h:6628
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
void SetRegExpIrregexpData(Handle< JSRegExp > regexp, JSRegExp::Type type, Handle< String > source, JSRegExp::Flags flags, int capture_count)
Definition: factory.cc:1381
Handle< AccessorPair > NewAccessorPair()
Definition: factory.cc:146
Handle< Context > NewNativeContext()
Definition: factory.cc:288
T Min(T a, T b)
Definition: utils.h:229
static const int kSize
Definition: objects.h:6312
Handle< Object > NewEvalError(const char *type, Vector< Handle< Object > > args)
Definition: factory.cc:686
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
Definition: flags.cc:495
static const int kUninitializedValue
Definition: objects.h:6682
Handle< Map > NewMap(InstanceType type, int instance_size, ElementsKind elements_kind=TERMINAL_FAST_ELEMENTS_KIND)
Definition: factory.cc:459
Handle< String > NewConsString(Handle< String > first, Handle< String > second)
Definition: factory.cc:243
static MUST_USE_RESULT MaybeObject * Allocate(int number_of_deopt_points, PretenureFlag pretenure)
Definition: objects.cc:6164
Handle< Object > NewNumberFromUint(uint32_t value, PretenureFlag pretenure=NOT_TENURED)
Definition: factory.cc:613
#define ARRAY_SIZE(a)
Definition: globals.h:281
Handle< ObjectHashSet > NewObjectHashSet(int at_least_space_for)
Definition: factory.cc:99
static MUST_USE_RESULT MaybeObject * Allocate(int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
Handle< JSGlobalPropertyCell > NewJSGlobalPropertyCell(Handle< Object > value)
Definition: factory.cc:450
Handle< UnseededNumberDictionary > NewUnseededNumberDictionary(int at_least_space_for)
Definition: factory.cc:90
void BecomeJSFunction(Handle< JSReceiver > object)
Definition: factory.cc:1015
Handle< Object > NewError(const char *maker, const char *type, Handle< JSArray > args)
Definition: factory.cc:735
Handle< SeededNumberDictionary > NewSeededNumberDictionary(int at_least_space_for)
Definition: factory.cc:81
static const int kLiteralsPrefixSize
Definition: objects.h:6194
static JSFunction * cast(Object *obj)