| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, | 51 Handle<FixedArray> Factory::NewFixedArrayWithHoles(int size, |
| 52 PretenureFlag pretenure) { | 52 PretenureFlag pretenure) { |
| 53 ASSERT(0 <= size); | 53 ASSERT(0 <= size); |
| 54 CALL_HEAP_FUNCTION( | 54 CALL_HEAP_FUNCTION( |
| 55 isolate(), | 55 isolate(), |
| 56 isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure), | 56 isolate()->heap()->AllocateFixedArrayWithHoles(size, pretenure), |
| 57 FixedArray); | 57 FixedArray); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 Handle<FixedArray> Factory::NewFixedDoubleArray(int size, |
| 62 PretenureFlag pretenure) { |
| 63 ASSERT(0 <= size); |
| 64 CALL_HEAP_FUNCTION( |
| 65 isolate(), |
| 66 isolate()->heap()->AllocateUninitializedFixedDoubleArray(size, pretenure), |
| 67 FixedArray); |
| 68 } |
| 69 |
| 70 |
| 61 Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) { | 71 Handle<StringDictionary> Factory::NewStringDictionary(int at_least_space_for) { |
| 62 ASSERT(0 <= at_least_space_for); | 72 ASSERT(0 <= at_least_space_for); |
| 63 CALL_HEAP_FUNCTION(isolate(), | 73 CALL_HEAP_FUNCTION(isolate(), |
| 64 StringDictionary::Allocate(at_least_space_for), | 74 StringDictionary::Allocate(at_least_space_for), |
| 65 StringDictionary); | 75 StringDictionary); |
| 66 } | 76 } |
| 67 | 77 |
| 68 | 78 |
| 69 Handle<NumberDictionary> Factory::NewNumberDictionary(int at_least_space_for) { | 79 Handle<NumberDictionary> Factory::NewNumberDictionary(int at_least_space_for) { |
| 70 ASSERT(0 <= at_least_space_for); | 80 ASSERT(0 <= at_least_space_for); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 172 |
| 163 Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, | 173 Handle<String> Factory::NewStringFromTwoByte(Vector<const uc16> string, |
| 164 PretenureFlag pretenure) { | 174 PretenureFlag pretenure) { |
| 165 CALL_HEAP_FUNCTION( | 175 CALL_HEAP_FUNCTION( |
| 166 isolate(), | 176 isolate(), |
| 167 isolate()->heap()->AllocateStringFromTwoByte(string, pretenure), | 177 isolate()->heap()->AllocateStringFromTwoByte(string, pretenure), |
| 168 String); | 178 String); |
| 169 } | 179 } |
| 170 | 180 |
| 171 | 181 |
| 172 Handle<String> Factory::NewRawAsciiString(int length, | 182 Handle<SeqAsciiString> Factory::NewRawAsciiString(int length, |
| 173 PretenureFlag pretenure) { | 183 PretenureFlag pretenure) { |
| 174 CALL_HEAP_FUNCTION( | 184 CALL_HEAP_FUNCTION( |
| 175 isolate(), | 185 isolate(), |
| 176 isolate()->heap()->AllocateRawAsciiString(length, pretenure), | 186 isolate()->heap()->AllocateRawAsciiString(length, pretenure), |
| 177 String); | 187 SeqAsciiString); |
| 178 } | 188 } |
| 179 | 189 |
| 180 | 190 |
| 181 Handle<String> Factory::NewRawTwoByteString(int length, | 191 Handle<SeqTwoByteString> Factory::NewRawTwoByteString(int length, |
| 182 PretenureFlag pretenure) { | 192 PretenureFlag pretenure) { |
| 183 CALL_HEAP_FUNCTION( | 193 CALL_HEAP_FUNCTION( |
| 184 isolate(), | 194 isolate(), |
| 185 isolate()->heap()->AllocateRawTwoByteString(length, pretenure), | 195 isolate()->heap()->AllocateRawTwoByteString(length, pretenure), |
| 186 String); | 196 SeqTwoByteString); |
| 187 } | 197 } |
| 188 | 198 |
| 189 | 199 |
| 190 Handle<String> Factory::NewConsString(Handle<String> first, | 200 Handle<String> Factory::NewConsString(Handle<String> first, |
| 191 Handle<String> second) { | 201 Handle<String> second) { |
| 192 CALL_HEAP_FUNCTION(isolate(), | 202 CALL_HEAP_FUNCTION(isolate(), |
| 193 isolate()->heap()->AllocateConsString(*first, *second), | 203 isolate()->heap()->AllocateConsString(*first, *second), |
| 194 String); | 204 String); |
| 195 } | 205 } |
| 196 | 206 |
| 197 | 207 |
| 198 Handle<String> Factory::NewSubString(Handle<String> str, | 208 Handle<String> Factory::NewSubString(Handle<String> str, |
| 199 int begin, | 209 int begin, |
| 200 int end) { | 210 int end) { |
| 201 CALL_HEAP_FUNCTION(isolate(), | 211 CALL_HEAP_FUNCTION(isolate(), |
| 202 str->SubString(begin, end), | 212 str->SubString(begin, end), |
| 203 String); | 213 String); |
| 204 } | 214 } |
| 205 | 215 |
| 206 | 216 |
| 217 Handle<String> Factory::NewProperSubString(Handle<String> str, |
| 218 int begin, |
| 219 int end) { |
| 220 ASSERT(begin > 0 || end < str->length()); |
| 221 CALL_HEAP_FUNCTION(isolate(), |
| 222 isolate()->heap()->AllocateSubString(*str, begin, end), |
| 223 String); |
| 224 } |
| 225 |
| 226 |
| 207 Handle<String> Factory::NewExternalStringFromAscii( | 227 Handle<String> Factory::NewExternalStringFromAscii( |
| 208 ExternalAsciiString::Resource* resource) { | 228 ExternalAsciiString::Resource* resource) { |
| 209 CALL_HEAP_FUNCTION( | 229 CALL_HEAP_FUNCTION( |
| 210 isolate(), | 230 isolate(), |
| 211 isolate()->heap()->AllocateExternalStringFromAscii(resource), | 231 isolate()->heap()->AllocateExternalStringFromAscii(resource), |
| 212 String); | 232 String); |
| 213 } | 233 } |
| 214 | 234 |
| 215 | 235 |
| 216 Handle<String> Factory::NewExternalStringFromTwoByte( | 236 Handle<String> Factory::NewExternalStringFromTwoByte( |
| 217 ExternalTwoByteString::Resource* resource) { | 237 ExternalTwoByteString::Resource* resource) { |
| 218 CALL_HEAP_FUNCTION( | 238 CALL_HEAP_FUNCTION( |
| 219 isolate(), | 239 isolate(), |
| 220 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), | 240 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), |
| 221 String); | 241 String); |
| 222 } | 242 } |
| 223 | 243 |
| 224 | 244 |
| 225 Handle<Context> Factory::NewGlobalContext() { | 245 Handle<Context> Factory::NewGlobalContext() { |
| 226 CALL_HEAP_FUNCTION( | 246 CALL_HEAP_FUNCTION( |
| 227 isolate(), | 247 isolate(), |
| 228 isolate()->heap()->AllocateGlobalContext(), | 248 isolate()->heap()->AllocateGlobalContext(), |
| 229 Context); | 249 Context); |
| 230 } | 250 } |
| 231 | 251 |
| 232 | 252 |
| 233 Handle<Context> Factory::NewFunctionContext(int length, | 253 Handle<Context> Factory::NewFunctionContext(int length, |
| 234 Handle<JSFunction> closure) { | 254 Handle<JSFunction> function) { |
| 235 CALL_HEAP_FUNCTION( | 255 CALL_HEAP_FUNCTION( |
| 236 isolate(), | 256 isolate(), |
| 237 isolate()->heap()->AllocateFunctionContext(length, *closure), | 257 isolate()->heap()->AllocateFunctionContext(length, *function), |
| 238 Context); | 258 Context); |
| 239 } | 259 } |
| 240 | 260 |
| 241 | 261 |
| 242 Handle<Context> Factory::NewWithContext(Handle<Context> previous, | 262 Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, |
| 243 Handle<JSObject> extension, | 263 Handle<Context> previous, |
| 244 bool is_catch_context) { | 264 Handle<String> name, |
| 265 Handle<Object> thrown_object) { |
| 245 CALL_HEAP_FUNCTION( | 266 CALL_HEAP_FUNCTION( |
| 246 isolate(), | 267 isolate(), |
| 247 isolate()->heap()->AllocateWithContext(*previous, | 268 isolate()->heap()->AllocateCatchContext(*function, |
| 248 *extension, | 269 *previous, |
| 249 is_catch_context), | 270 *name, |
| 271 *thrown_object), |
| 272 Context); |
| 273 } |
| 274 |
| 275 |
| 276 Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, |
| 277 Handle<Context> previous, |
| 278 Handle<JSObject> extension) { |
| 279 CALL_HEAP_FUNCTION( |
| 280 isolate(), |
| 281 isolate()->heap()->AllocateWithContext(*function, *previous, *extension), |
| 250 Context); | 282 Context); |
| 251 } | 283 } |
| 252 | 284 |
| 253 | 285 |
| 254 Handle<Struct> Factory::NewStruct(InstanceType type) { | 286 Handle<Struct> Factory::NewStruct(InstanceType type) { |
| 255 CALL_HEAP_FUNCTION( | 287 CALL_HEAP_FUNCTION( |
| 256 isolate(), | 288 isolate(), |
| 257 isolate()->heap()->AllocateStruct(type), | 289 isolate()->heap()->AllocateStruct(type), |
| 258 Struct); | 290 Struct); |
| 259 } | 291 } |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 store->set(JSRegExp::kAtomPatternIndex, *data); | 1214 store->set(JSRegExp::kAtomPatternIndex, *data); |
| 1183 regexp->set_data(*store); | 1215 regexp->set_data(*store); |
| 1184 } | 1216 } |
| 1185 | 1217 |
| 1186 void Factory::SetRegExpIrregexpData(Handle<JSRegExp> regexp, | 1218 void Factory::SetRegExpIrregexpData(Handle<JSRegExp> regexp, |
| 1187 JSRegExp::Type type, | 1219 JSRegExp::Type type, |
| 1188 Handle<String> source, | 1220 Handle<String> source, |
| 1189 JSRegExp::Flags flags, | 1221 JSRegExp::Flags flags, |
| 1190 int capture_count) { | 1222 int capture_count) { |
| 1191 Handle<FixedArray> store = NewFixedArray(JSRegExp::kIrregexpDataSize); | 1223 Handle<FixedArray> store = NewFixedArray(JSRegExp::kIrregexpDataSize); |
| 1192 | 1224 Smi* uninitialized = Smi::FromInt(JSRegExp::kUninitializedValue); |
| 1193 store->set(JSRegExp::kTagIndex, Smi::FromInt(type)); | 1225 store->set(JSRegExp::kTagIndex, Smi::FromInt(type)); |
| 1194 store->set(JSRegExp::kSourceIndex, *source); | 1226 store->set(JSRegExp::kSourceIndex, *source); |
| 1195 store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value())); | 1227 store->set(JSRegExp::kFlagsIndex, Smi::FromInt(flags.value())); |
| 1196 store->set(JSRegExp::kIrregexpASCIICodeIndex, HEAP->the_hole_value()); | 1228 store->set(JSRegExp::kIrregexpASCIICodeIndex, uninitialized); |
| 1197 store->set(JSRegExp::kIrregexpUC16CodeIndex, HEAP->the_hole_value()); | 1229 store->set(JSRegExp::kIrregexpUC16CodeIndex, uninitialized); |
| 1230 store->set(JSRegExp::kIrregexpASCIICodeSavedIndex, uninitialized); |
| 1231 store->set(JSRegExp::kIrregexpUC16CodeSavedIndex, uninitialized); |
| 1198 store->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(0)); | 1232 store->set(JSRegExp::kIrregexpMaxRegisterCountIndex, Smi::FromInt(0)); |
| 1199 store->set(JSRegExp::kIrregexpCaptureCountIndex, | 1233 store->set(JSRegExp::kIrregexpCaptureCountIndex, |
| 1200 Smi::FromInt(capture_count)); | 1234 Smi::FromInt(capture_count)); |
| 1201 regexp->set_data(*store); | 1235 regexp->set_data(*store); |
| 1202 } | 1236 } |
| 1203 | 1237 |
| 1204 | 1238 |
| 1205 | 1239 |
| 1206 void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, | 1240 void Factory::ConfigureInstance(Handle<FunctionTemplateInfo> desc, |
| 1207 Handle<JSObject> instance, | 1241 Handle<JSObject> instance, |
| 1208 bool* pending_exception) { | 1242 bool* pending_exception) { |
| 1209 // Configure the instance by adding the properties specified by the | 1243 // Configure the instance by adding the properties specified by the |
| 1210 // instance template. | 1244 // instance template. |
| 1211 Handle<Object> instance_template = Handle<Object>(desc->instance_template()); | 1245 Handle<Object> instance_template = Handle<Object>(desc->instance_template()); |
| 1212 if (!instance_template->IsUndefined()) { | 1246 if (!instance_template->IsUndefined()) { |
| 1213 Execution::ConfigureInstance(instance, | 1247 Execution::ConfigureInstance(instance, |
| 1214 instance_template, | 1248 instance_template, |
| 1215 pending_exception); | 1249 pending_exception); |
| 1216 } else { | 1250 } else { |
| 1217 *pending_exception = false; | 1251 *pending_exception = false; |
| 1218 } | 1252 } |
| 1219 } | 1253 } |
| 1220 | 1254 |
| 1221 | 1255 |
| 1222 } } // namespace v8::internal | 1256 } } // namespace v8::internal |
| OLD | NEW |