OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 int index = Smi::cast(args[1])->value(); | 3486 int index = Smi::cast(args[1])->value(); |
3487 Handle<Object> result = GetCharAt(str, index); | 3487 Handle<Object> result = GetCharAt(str, index); |
3488 return *result; | 3488 return *result; |
3489 } | 3489 } |
3490 | 3490 |
3491 // Fall back to GetObjectProperty. | 3491 // Fall back to GetObjectProperty. |
3492 return Runtime::GetObjectProperty(args.at<Object>(0), | 3492 return Runtime::GetObjectProperty(args.at<Object>(0), |
3493 args.at<Object>(1)); | 3493 args.at<Object>(1)); |
3494 } | 3494 } |
3495 | 3495 |
3496 | 3496 // Implements part of 8.12.9 DefineOwnProperty. |
| 3497 // There are 3 cases that lead here: |
| 3498 // Step 4b - define a new accessor property. |
| 3499 // Steps 9c & 12 - replace an existing data property with an accessor property. |
| 3500 // Step 12 - update an existing accessor property with an accessor or generic |
| 3501 // descriptor. |
3497 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { | 3502 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { |
3498 ASSERT(args.length() == 5); | 3503 ASSERT(args.length() == 5); |
3499 HandleScope scope; | 3504 HandleScope scope; |
3500 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 3505 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
3501 CONVERT_CHECKED(String, name, args[1]); | 3506 CONVERT_CHECKED(String, name, args[1]); |
3502 CONVERT_CHECKED(Smi, flag_setter, args[2]); | 3507 CONVERT_CHECKED(Smi, flag_setter, args[2]); |
3503 Object* fun = args[3]; | 3508 Object* fun = args[3]; |
3504 RUNTIME_ASSERT(fun->IsJSFunction() || fun->IsUndefined()); | 3509 RUNTIME_ASSERT(fun->IsJSFunction() || fun->IsUndefined()); |
3505 CONVERT_CHECKED(Smi, flag_attr, args[4]); | 3510 CONVERT_CHECKED(Smi, flag_attr, args[4]); |
3506 int unchecked = flag_attr->value(); | 3511 int unchecked = flag_attr->value(); |
(...skipping 11 matching lines...) Expand all Loading... |
3518 || result.type() == CONSTANT_FUNCTION)) { | 3523 || result.type() == CONSTANT_FUNCTION)) { |
3519 Object* ok; | 3524 Object* ok; |
3520 { MaybeObject* maybe_ok = | 3525 { MaybeObject* maybe_ok = |
3521 obj->DeleteProperty(name, JSObject::NORMAL_DELETION); | 3526 obj->DeleteProperty(name, JSObject::NORMAL_DELETION); |
3522 if (!maybe_ok->ToObject(&ok)) return maybe_ok; | 3527 if (!maybe_ok->ToObject(&ok)) return maybe_ok; |
3523 } | 3528 } |
3524 } | 3529 } |
3525 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); | 3530 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); |
3526 } | 3531 } |
3527 | 3532 |
| 3533 // Implements part of 8.12.9 DefineOwnProperty. |
| 3534 // There are 3 cases that lead here: |
| 3535 // Step 4a - define a new data property. |
| 3536 // Steps 9b & 12 - replace an existing accessor property with a data property. |
| 3537 // Step 12 - update an existing data property with a data or generic |
| 3538 // descriptor. |
3528 static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) { | 3539 static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) { |
3529 ASSERT(args.length() == 4); | 3540 ASSERT(args.length() == 4); |
3530 HandleScope scope; | 3541 HandleScope scope; |
3531 CONVERT_ARG_CHECKED(JSObject, js_object, 0); | 3542 CONVERT_ARG_CHECKED(JSObject, js_object, 0); |
3532 CONVERT_ARG_CHECKED(String, name, 1); | 3543 CONVERT_ARG_CHECKED(String, name, 1); |
3533 Handle<Object> obj_value = args.at<Object>(2); | 3544 Handle<Object> obj_value = args.at<Object>(2); |
3534 | 3545 |
3535 CONVERT_CHECKED(Smi, flag, args[3]); | 3546 CONVERT_CHECKED(Smi, flag, args[3]); |
3536 int unchecked = flag->value(); | 3547 int unchecked = flag->value(); |
3537 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 3548 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
(...skipping 7258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10796 } else { | 10807 } else { |
10797 // Handle last resort GC and make sure to allow future allocations | 10808 // Handle last resort GC and make sure to allow future allocations |
10798 // to grow the heap without causing GCs (if possible). | 10809 // to grow the heap without causing GCs (if possible). |
10799 Counters::gc_last_resort_from_js.Increment(); | 10810 Counters::gc_last_resort_from_js.Increment(); |
10800 Heap::CollectAllGarbage(false); | 10811 Heap::CollectAllGarbage(false); |
10801 } | 10812 } |
10802 } | 10813 } |
10803 | 10814 |
10804 | 10815 |
10805 } } // namespace v8::internal | 10816 } } // namespace v8::internal |
OLD | NEW |