OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 Handle<Object> object = CreateArrayLiteralBoilerplate(literals, elements); | 392 Handle<Object> object = CreateArrayLiteralBoilerplate(literals, elements); |
393 if (object.is_null()) return Failure::Exception(); | 393 if (object.is_null()) return Failure::Exception(); |
394 | 394 |
395 // Update the functions literal and return the boilerplate. | 395 // Update the functions literal and return the boilerplate. |
396 literals->set(literals_index, *object); | 396 literals->set(literals_index, *object); |
397 return *object; | 397 return *object; |
398 } | 398 } |
399 | 399 |
400 | 400 |
| 401 static Object* Runtime_CreateObjectLiteral(Arguments args) { |
| 402 HandleScope scope; |
| 403 ASSERT(args.length() == 3); |
| 404 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
| 405 CONVERT_SMI_CHECKED(literals_index, args[1]); |
| 406 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); |
| 407 |
| 408 // Check if boilerplate exists. If not, create it first. |
| 409 Handle<Object> boilerplate(literals->get(literals_index)); |
| 410 if (*boilerplate == Heap::undefined_value()) { |
| 411 boilerplate = CreateObjectLiteralBoilerplate(literals, constant_properties); |
| 412 if (boilerplate.is_null()) return Failure::Exception(); |
| 413 // Update the functions literal and return the boilerplate. |
| 414 literals->set(literals_index, *boilerplate); |
| 415 } |
| 416 return DeepCopyBoilerplate(JSObject::cast(*boilerplate)); |
| 417 } |
| 418 |
| 419 |
| 420 static Object* Runtime_CreateObjectLiteralShallow(Arguments args) { |
| 421 HandleScope scope; |
| 422 ASSERT(args.length() == 3); |
| 423 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
| 424 CONVERT_SMI_CHECKED(literals_index, args[1]); |
| 425 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); |
| 426 |
| 427 // Check if boilerplate exists. If not, create it first. |
| 428 Handle<Object> boilerplate(literals->get(literals_index)); |
| 429 if (*boilerplate == Heap::undefined_value()) { |
| 430 boilerplate = CreateObjectLiteralBoilerplate(literals, constant_properties); |
| 431 if (boilerplate.is_null()) return Failure::Exception(); |
| 432 // Update the functions literal and return the boilerplate. |
| 433 literals->set(literals_index, *boilerplate); |
| 434 } |
| 435 return Heap::CopyJSObject(JSObject::cast(*boilerplate)); |
| 436 } |
| 437 |
| 438 |
| 439 static Object* Runtime_CreateArrayLiteral(Arguments args) { |
| 440 HandleScope scope; |
| 441 ASSERT(args.length() == 3); |
| 442 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
| 443 CONVERT_SMI_CHECKED(literals_index, args[1]); |
| 444 CONVERT_ARG_CHECKED(FixedArray, elements, 2); |
| 445 |
| 446 // Check if boilerplate exists. If not, create it first. |
| 447 Handle<Object> boilerplate(literals->get(literals_index)); |
| 448 if (*boilerplate == Heap::undefined_value()) { |
| 449 boilerplate = CreateArrayLiteralBoilerplate(literals, elements); |
| 450 if (boilerplate.is_null()) return Failure::Exception(); |
| 451 // Update the functions literal and return the boilerplate. |
| 452 literals->set(literals_index, *boilerplate); |
| 453 } |
| 454 return DeepCopyBoilerplate(JSObject::cast(*boilerplate)); |
| 455 } |
| 456 |
| 457 |
| 458 static Object* Runtime_CreateArrayLiteralShallow(Arguments args) { |
| 459 HandleScope scope; |
| 460 ASSERT(args.length() == 3); |
| 461 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
| 462 CONVERT_SMI_CHECKED(literals_index, args[1]); |
| 463 CONVERT_ARG_CHECKED(FixedArray, elements, 2); |
| 464 |
| 465 // Check if boilerplate exists. If not, create it first. |
| 466 Handle<Object> boilerplate(literals->get(literals_index)); |
| 467 if (*boilerplate == Heap::undefined_value()) { |
| 468 boilerplate = CreateArrayLiteralBoilerplate(literals, elements); |
| 469 if (boilerplate.is_null()) return Failure::Exception(); |
| 470 // Update the functions literal and return the boilerplate. |
| 471 literals->set(literals_index, *boilerplate); |
| 472 } |
| 473 return Heap::CopyJSObject(JSObject::cast(*boilerplate)); |
| 474 } |
| 475 |
| 476 |
401 static Object* Runtime_CreateCatchExtensionObject(Arguments args) { | 477 static Object* Runtime_CreateCatchExtensionObject(Arguments args) { |
402 ASSERT(args.length() == 2); | 478 ASSERT(args.length() == 2); |
403 CONVERT_CHECKED(String, key, args[0]); | 479 CONVERT_CHECKED(String, key, args[0]); |
404 Object* value = args[1]; | 480 Object* value = args[1]; |
405 // Create a catch context extension object. | 481 // Create a catch context extension object. |
406 JSFunction* constructor = | 482 JSFunction* constructor = |
407 Top::context()->global_context()->context_extension_function(); | 483 Top::context()->global_context()->context_extension_function(); |
408 Object* object = Heap::AllocateJSObject(constructor); | 484 Object* object = Heap::AllocateJSObject(constructor); |
409 if (object->IsFailure()) return object; | 485 if (object->IsFailure()) return object; |
410 // Assign the exception value to the catch variable and make sure | 486 // Assign the exception value to the catch variable and make sure |
(...skipping 7551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7962 } else { | 8038 } else { |
7963 // Handle last resort GC and make sure to allow future allocations | 8039 // Handle last resort GC and make sure to allow future allocations |
7964 // to grow the heap without causing GCs (if possible). | 8040 // to grow the heap without causing GCs (if possible). |
7965 Counters::gc_last_resort_from_js.Increment(); | 8041 Counters::gc_last_resort_from_js.Increment(); |
7966 Heap::CollectAllGarbage(false); | 8042 Heap::CollectAllGarbage(false); |
7967 } | 8043 } |
7968 } | 8044 } |
7969 | 8045 |
7970 | 8046 |
7971 } } // namespace v8::internal | 8047 } } // namespace v8::internal |
OLD | NEW |