Revision f230a1cf deps/v8/src/factory.cc

View differences:

deps/v8/src/factory.cc
79 79
}
80 80

  
81 81

  
82
Handle<ConstantPoolArray> Factory::NewConstantPoolArray(
83
    int number_of_int64_entries,
84
    int number_of_ptr_entries,
85
    int number_of_int32_entries) {
86
  ASSERT(number_of_int64_entries > 0 || number_of_ptr_entries > 0 ||
87
         number_of_int32_entries > 0);
88
  CALL_HEAP_FUNCTION(
89
      isolate(),
90
      isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries,
91
                                                   number_of_ptr_entries,
92
                                                   number_of_int32_entries),
93
      ConstantPoolArray);
94
}
95

  
96

  
82 97
Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) {
83 98
  ASSERT(0 <= at_least_space_for);
84 99
  CALL_HEAP_FUNCTION(isolate(),
......
126 141
}
127 142

  
128 143

  
144
Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) {
145
  ASSERT(0 <= at_least_space_for);
146
  CALL_HEAP_FUNCTION(
147
      isolate(),
148
      WeakHashTable::Allocate(isolate()->heap(),
149
                              at_least_space_for,
150
                              WeakHashTable::USE_DEFAULT_MINIMUM_CAPACITY,
151
                              TENURED),
152
      WeakHashTable);
153
}
154

  
155

  
129 156
Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors,
130 157
                                                    int slack) {
131 158
  ASSERT(0 <= number_of_descriptors);
......
511 538
}
512 539

  
513 540

  
514
Handle<PropertyCell> Factory::NewPropertyCell(Handle<Object> value) {
515
  AllowDeferredHandleDereference convert_to_cell;
541
Handle<PropertyCell> Factory::NewPropertyCellWithHole() {
516 542
  CALL_HEAP_FUNCTION(
517 543
      isolate(),
518
      isolate()->heap()->AllocatePropertyCell(*value),
544
      isolate()->heap()->AllocatePropertyCell(),
519 545
      PropertyCell);
520 546
}
521 547

  
522 548

  
549
Handle<PropertyCell> Factory::NewPropertyCell(Handle<Object> value) {
550
  AllowDeferredHandleDereference convert_to_cell;
551
  Handle<PropertyCell> cell = NewPropertyCellWithHole();
552
  PropertyCell::SetValueInferType(cell, value);
553
  return cell;
554
}
555

  
556

  
523 557
Handle<AllocationSite> Factory::NewAllocationSite() {
524 558
  CALL_HEAP_FUNCTION(
525 559
      isolate(),
......
598 632

  
599 633

  
600 634
Handle<FixedArray> Factory::CopySizeFixedArray(Handle<FixedArray> array,
601
                                               int new_length) {
602
  CALL_HEAP_FUNCTION(isolate(), array->CopySize(new_length), FixedArray);
635
                                               int new_length,
636
                                               PretenureFlag pretenure) {
637
  CALL_HEAP_FUNCTION(isolate(),
638
                     array->CopySize(new_length, pretenure),
639
                     FixedArray);
603 640
}
604 641

  
605 642

  
......
609 646
}
610 647

  
611 648

  
649
Handle<ConstantPoolArray> Factory::CopyConstantPoolArray(
650
    Handle<ConstantPoolArray> array) {
651
  CALL_HEAP_FUNCTION(isolate(), array->Copy(), ConstantPoolArray);
652
}
653

  
654

  
612 655
Handle<JSFunction> Factory::BaseNewFunctionFromSharedFunctionInfo(
613 656
    Handle<SharedFunctionInfo> function_info,
614 657
    Handle<Map> function_map,
......
972 1015
                              Code::Flags flags,
973 1016
                              Handle<Object> self_ref,
974 1017
                              bool immovable,
975
                              bool crankshafted) {
1018
                              bool crankshafted,
1019
                              int prologue_offset) {
976 1020
  CALL_HEAP_FUNCTION(isolate(),
977 1021
                     isolate()->heap()->CreateCode(
978
                         desc, flags, self_ref, immovable, crankshafted),
1022
                         desc, flags, self_ref, immovable, crankshafted,
1023
                         prologue_offset),
979 1024
                     Code);
980 1025
}
981 1026

  
......
1016 1061
}
1017 1062

  
1018 1063

  
1019
Handle<GlobalObject> Factory::NewGlobalObject(
1020
    Handle<JSFunction> constructor) {
1021
  CALL_HEAP_FUNCTION(isolate(),
1022
                     isolate()->heap()->AllocateGlobalObject(*constructor),
1064
// TODO(mstarzinger): Temporary wrapper until handlified.
1065
static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
1066
                                                Handle<Name> name,
1067
                                                Handle<Object> value,
1068
                                                PropertyDetails details) {
1069
  CALL_HEAP_FUNCTION(dict->GetIsolate(),
1070
                     dict->Add(*name, *value, details),
1071
                     NameDictionary);
1072
}
1073

  
1074

  
1075
static Handle<GlobalObject> NewGlobalObjectFromMap(Isolate* isolate,
1076
                                                   Handle<Map> map) {
1077
  CALL_HEAP_FUNCTION(isolate,
1078
                     isolate->heap()->Allocate(*map, OLD_POINTER_SPACE),
1023 1079
                     GlobalObject);
1024 1080
}
1025 1081

  
1026 1082

  
1083
Handle<GlobalObject> Factory::NewGlobalObject(Handle<JSFunction> constructor) {
1084
  ASSERT(constructor->has_initial_map());
1085
  Handle<Map> map(constructor->initial_map());
1086
  ASSERT(map->is_dictionary_map());
1087

  
1088
  // Make sure no field properties are described in the initial map.
1089
  // This guarantees us that normalizing the properties does not
1090
  // require us to change property values to PropertyCells.
1091
  ASSERT(map->NextFreePropertyIndex() == 0);
1092

  
1093
  // Make sure we don't have a ton of pre-allocated slots in the
1094
  // global objects. They will be unused once we normalize the object.
1095
  ASSERT(map->unused_property_fields() == 0);
1096
  ASSERT(map->inobject_properties() == 0);
1097

  
1098
  // Initial size of the backing store to avoid resize of the storage during
1099
  // bootstrapping. The size differs between the JS global object ad the
1100
  // builtins object.
1101
  int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512;
1102

  
1103
  // Allocate a dictionary object for backing storage.
1104
  int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size;
1105
  Handle<NameDictionary> dictionary = NewNameDictionary(at_least_space_for);
1106

  
1107
  // The global object might be created from an object template with accessors.
1108
  // Fill these accessors into the dictionary.
1109
  Handle<DescriptorArray> descs(map->instance_descriptors());
1110
  for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
1111
    PropertyDetails details = descs->GetDetails(i);
1112
    ASSERT(details.type() == CALLBACKS);  // Only accessors are expected.
1113
    PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1);
1114
    Handle<Name> name(descs->GetKey(i));
1115
    Handle<Object> value(descs->GetCallbacksObject(i), isolate());
1116
    Handle<PropertyCell> cell = NewPropertyCell(value);
1117
    NameDictionaryAdd(dictionary, name, cell, d);
1118
  }
1119

  
1120
  // Allocate the global object and initialize it with the backing store.
1121
  Handle<GlobalObject> global = NewGlobalObjectFromMap(isolate(), map);
1122
  isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map);
1123

  
1124
  // Create a new map for the global object.
1125
  Handle<Map> new_map = Map::CopyDropDescriptors(map);
1126
  new_map->set_dictionary_map(true);
1127

  
1128
  // Set up the global object as a normalized object.
1129
  global->set_map(*new_map);
1130
  global->set_properties(*dictionary);
1131

  
1132
  // Make sure result is a global object with properties in dictionary.
1133
  ASSERT(global->IsGlobalObject() && !global->HasFastProperties());
1134
  return global;
1135
}
1136

  
1027 1137

  
1028 1138
Handle<JSObject> Factory::NewJSObjectFromMap(Handle<Map> map,
1029 1139
                                             PretenureFlag pretenure,
......
1083 1193
}
1084 1194

  
1085 1195

  
1086
void Factory::EnsureCanContainElements(Handle<JSArray> array,
1087
                                       Handle<FixedArrayBase> elements,
1088
                                       uint32_t length,
1089
                                       EnsureElementsMode mode) {
1090
  CALL_HEAP_FUNCTION_VOID(
1091
      isolate(),
1092
      array->EnsureCanContainElements(*elements, length, mode));
1093
}
1094

  
1095

  
1096 1196
Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
1097 1197
  Handle<JSFunction> array_buffer_fun(
1098 1198
      isolate()->context()->native_context()->array_buffer_fun());

Also available in: Unified diff