OLD | NEW |
---|---|
1 // Copyright 2011 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 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 | 235 |
236 Handle<String> Factory::NewExternalStringFromTwoByte( | 236 Handle<String> Factory::NewExternalStringFromTwoByte( |
237 ExternalTwoByteString::Resource* resource) { | 237 ExternalTwoByteString::Resource* resource) { |
238 CALL_HEAP_FUNCTION( | 238 CALL_HEAP_FUNCTION( |
239 isolate(), | 239 isolate(), |
240 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), | 240 isolate()->heap()->AllocateExternalStringFromTwoByte(resource), |
241 String); | 241 String); |
242 } | 242 } |
243 | 243 |
244 | 244 |
245 static Handle<JSValue> AllocateJSValue(Isolate* isolate, | |
246 JSFunction* constructor) { | |
247 CALL_HEAP_FUNCTION( | |
248 isolate, | |
249 isolate->heap()->AllocateJSObject(constructor), | |
Vyacheslav Egorov (Chromium)
2011/07/12 20:38:12
constructor will be "dead variable" if GC happens.
zarko
2011/07/12 21:42:06
Done.
| |
250 JSValue); | |
251 } | |
252 | |
253 | |
254 static Handle<Object> CreateJSValue(Isolate* isolate, | |
255 JSFunction* constructor, | |
256 Handle<Object> value) { | |
257 Handle<JSValue> raw_value = AllocateJSValue(isolate, constructor); | |
258 if (!raw_value.is_null()) { | |
259 raw_value->set_value(*value); | |
260 } | |
261 return raw_value; | |
262 } | |
263 | |
264 | |
265 Handle<Object> Factory::NewBoxedString(Handle<String> value) { | |
266 return CreateJSValue(isolate(), | |
267 isolate()->global_context()->string_function(), | |
268 value); | |
269 } | |
270 | |
271 | |
272 Handle<Object> Factory::NewBoxedBoolean(bool value) { | |
273 Handle<Object> boolean(value ? isolate()->heap()->true_value() | |
274 : isolate()->heap()->false_value()); | |
275 return CreateJSValue(isolate(), | |
276 isolate()->global_context()->boolean_function(), | |
277 boolean); | |
278 } | |
279 | |
280 | |
281 Handle<Object> Factory::NewBoxedNumber(double value) { | |
282 Handle<Object> number = NewNumber(value); | |
283 return CreateJSValue(isolate(), | |
284 isolate()->global_context()->number_function(), | |
285 number); | |
286 } | |
287 | |
288 | |
245 Handle<Context> Factory::NewGlobalContext() { | 289 Handle<Context> Factory::NewGlobalContext() { |
246 CALL_HEAP_FUNCTION( | 290 CALL_HEAP_FUNCTION( |
247 isolate(), | 291 isolate(), |
248 isolate()->heap()->AllocateGlobalContext(), | 292 isolate()->heap()->AllocateGlobalContext(), |
249 Context); | 293 Context); |
250 } | 294 } |
251 | 295 |
252 | 296 |
253 Handle<Context> Factory::NewFunctionContext(int length, | 297 Handle<Context> Factory::NewFunctionContext(int length, |
254 Handle<JSFunction> function) { | 298 Handle<JSFunction> function) { |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 Execution::ConfigureInstance(instance, | 1291 Execution::ConfigureInstance(instance, |
1248 instance_template, | 1292 instance_template, |
1249 pending_exception); | 1293 pending_exception); |
1250 } else { | 1294 } else { |
1251 *pending_exception = false; | 1295 *pending_exception = false; |
1252 } | 1296 } |
1253 } | 1297 } |
1254 | 1298 |
1255 | 1299 |
1256 } } // namespace v8::internal | 1300 } } // namespace v8::internal |
OLD | NEW |