~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to src/factory.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
}
78
78
 
79
79
 
80
 
Handle<NumberDictionary> Factory::NewNumberDictionary(int at_least_space_for) {
81
 
  ASSERT(0 <= at_least_space_for);
82
 
  CALL_HEAP_FUNCTION(isolate(),
83
 
                     NumberDictionary::Allocate(at_least_space_for),
84
 
                     NumberDictionary);
 
80
Handle<SeededNumberDictionary> Factory::NewSeededNumberDictionary(
 
81
    int at_least_space_for) {
 
82
  ASSERT(0 <= at_least_space_for);
 
83
  CALL_HEAP_FUNCTION(isolate(),
 
84
                     SeededNumberDictionary::Allocate(at_least_space_for),
 
85
                     SeededNumberDictionary);
 
86
}
 
87
 
 
88
 
 
89
Handle<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);
85
95
}
86
96
 
87
97
 
131
141
}
132
142
 
133
143
 
 
144
Handle<AccessorPair> Factory::NewAccessorPair() {
 
145
  CALL_HEAP_FUNCTION(isolate(),
 
146
                     isolate()->heap()->AllocateAccessorPair(),
 
147
                     AccessorPair);
 
148
}
 
149
 
 
150
 
134
151
// Symbols are created in the old generation (data space).
135
152
Handle<String> Factory::LookupSymbol(Vector<const char> string) {
136
153
  CALL_HEAP_FUNCTION(isolate(),
698
715
  // Allocate the function
699
716
  Handle<JSFunction> function = NewFunction(name, the_hole_value());
700
717
 
701
 
  // Setup the code pointer in both the shared function info and in
 
718
  // Set up the code pointer in both the shared function info and in
702
719
  // the function itself.
703
720
  function->shared()->set_code(*code);
704
721
  function->set_code(*code);
729
746
  // Allocate the function.
730
747
  Handle<JSFunction> function = NewFunction(name, prototype);
731
748
 
732
 
  // Setup the code pointer in both the shared function info and in
 
749
  // Set up the code pointer in both the shared function info and in
733
750
  // the function itself.
734
751
  function->shared()->set_code(*code);
735
752
  function->set_code(*code);
751
768
  // property that refers to the function.
752
769
  SetPrototypeProperty(function, prototype);
753
770
  // Currently safe because it is only invoked from Genesis.
754
 
  SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM);
 
771
  CHECK_NOT_EMPTY_HANDLE(isolate(),
 
772
                         JSObject::SetLocalPropertyIgnoreAttributes(
 
773
                             prototype, constructor_symbol(),
 
774
                             function, DONT_ENUM));
755
775
  return function;
756
776
}
757
777
 
926
946
}
927
947
 
928
948
 
929
 
Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArray> elements,
 
949
Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
930
950
                                                PretenureFlag pretenure) {
931
951
  Handle<JSArray> result =
932
952
      Handle<JSArray>::cast(NewJSObject(isolate()->array_function(),
933
953
                                        pretenure));
 
954
  result->set_length(Smi::FromInt(0));
934
955
  SetContent(result, elements);
935
956
  return result;
936
957
}
937
958
 
938
959
 
 
960
void 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
 
939
970
void Factory::SetContent(Handle<JSArray> array,
940
 
                         Handle<FixedArray> elements) {
 
971
                         Handle<FixedArrayBase> elements) {
941
972
  CALL_HEAP_FUNCTION_VOID(
942
973
      isolate(),
943
974
      array->SetContent(*elements));
944
975
}
945
976
 
946
977
 
947
 
void Factory::EnsureCanContainNonSmiElements(Handle<JSArray> array) {
948
 
  CALL_HEAP_FUNCTION_VOID(
949
 
      isolate(),
950
 
      array->EnsureCanContainNonSmiElements());
 
978
void Factory::EnsureCanContainHeapObjectElements(Handle<JSArray> array) {
 
979
  CALL_HEAP_FUNCTION_VOID(
 
980
      isolate(),
 
981
      array->EnsureCanContainHeapObjectElements());
 
982
}
 
983
 
 
984
 
 
985
void Factory::EnsureCanContainElements(Handle<JSArray> array,
 
986
                                       Handle<FixedArrayBase> elements,
 
987
                                       EnsureElementsMode mode) {
 
988
  CALL_HEAP_FUNCTION_VOID(
 
989
      isolate(),
 
990
      array->EnsureCanContainElements(*elements, mode));
951
991
}
952
992
 
953
993
 
1041
1081
}
1042
1082
 
1043
1083
 
1044
 
Handle<NumberDictionary> Factory::DictionaryAtNumberPut(
1045
 
    Handle<NumberDictionary> dictionary,
1046
 
    uint32_t key,
1047
 
    Handle<Object> value) {
1048
 
  CALL_HEAP_FUNCTION(isolate(),
1049
 
                     dictionary->AtNumberPut(key, *value),
1050
 
                     NumberDictionary);
 
1084
Handle<SeededNumberDictionary> Factory::DictionaryAtNumberPut(
 
1085
    Handle<SeededNumberDictionary> dictionary,
 
1086
    uint32_t key,
 
1087
    Handle<Object> value) {
 
1088
  CALL_HEAP_FUNCTION(isolate(),
 
1089
                     dictionary->AtNumberPut(key, *value),
 
1090
                     SeededNumberDictionary);
 
1091
}
 
1092
 
 
1093
 
 
1094
Handle<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);
1051
1101
}
1052
1102
 
1053
1103