| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 new_proto_map->set_is_hidden_prototype(); | 607 new_proto_map->set_is_hidden_prototype(); |
| 608 | 608 |
| 609 // Set the object's prototype to proto. | 609 // Set the object's prototype to proto. |
| 610 new_map->set_prototype(proto); | 610 new_map->set_prototype(proto); |
| 611 jsobject->set_map(new_map); | 611 jsobject->set_map(new_map); |
| 612 | 612 |
| 613 return Heap::undefined_value(); | 613 return Heap::undefined_value(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 | 616 |
| 617 // Sets the magic number that identifies a function as one of the special | |
| 618 // math functions that can be inlined. | |
| 619 static MaybeObject* Runtime_SetMathFunctionId(Arguments args) { | |
| 620 NoHandleAllocation ha; | |
| 621 ASSERT(args.length() == 2); | |
| 622 CONVERT_CHECKED(JSFunction, function, args[0]); | |
| 623 CONVERT_CHECKED(Smi, id, args[1]); | |
| 624 RUNTIME_ASSERT(id->value() >= 0); | |
| 625 RUNTIME_ASSERT(id->value() < SharedFunctionInfo::max_math_id_number()); | |
| 626 | |
| 627 function->shared()->set_math_function_id(id->value()); | |
| 628 | |
| 629 return Heap::undefined_value(); | |
| 630 } | |
| 631 | |
| 632 | |
| 633 static MaybeObject* Runtime_IsConstructCall(Arguments args) { | 617 static MaybeObject* Runtime_IsConstructCall(Arguments args) { |
| 634 NoHandleAllocation ha; | 618 NoHandleAllocation ha; |
| 635 ASSERT(args.length() == 0); | 619 ASSERT(args.length() == 0); |
| 636 JavaScriptFrameIterator it; | 620 JavaScriptFrameIterator it; |
| 637 return Heap::ToBoolean(it.frame()->IsConstructor()); | 621 return Heap::ToBoolean(it.frame()->IsConstructor()); |
| 638 } | 622 } |
| 639 | 623 |
| 640 | 624 |
| 641 // Recursively traverses hidden prototypes if property is not found | 625 // Recursively traverses hidden prototypes if property is not found |
| 642 static void GetOwnPropertyImplementation(JSObject* obj, | 626 static void GetOwnPropertyImplementation(JSObject* obj, |
| (...skipping 2866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3509 args.at<Object>(1)); | 3493 args.at<Object>(1)); |
| 3510 } | 3494 } |
| 3511 | 3495 |
| 3512 | 3496 |
| 3513 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { | 3497 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { |
| 3514 ASSERT(args.length() == 5); | 3498 ASSERT(args.length() == 5); |
| 3515 HandleScope scope; | 3499 HandleScope scope; |
| 3516 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 3500 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 3517 CONVERT_CHECKED(String, name, args[1]); | 3501 CONVERT_CHECKED(String, name, args[1]); |
| 3518 CONVERT_CHECKED(Smi, flag_setter, args[2]); | 3502 CONVERT_CHECKED(Smi, flag_setter, args[2]); |
| 3519 CONVERT_CHECKED(JSFunction, fun, args[3]); | 3503 Object* fun = args[3]; |
| 3504 RUNTIME_ASSERT(fun->IsJSFunction() || fun->IsUndefined()); |
| 3520 CONVERT_CHECKED(Smi, flag_attr, args[4]); | 3505 CONVERT_CHECKED(Smi, flag_attr, args[4]); |
| 3521 int unchecked = flag_attr->value(); | 3506 int unchecked = flag_attr->value(); |
| 3522 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 3507 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 3523 RUNTIME_ASSERT(!obj->IsNull()); | 3508 RUNTIME_ASSERT(!obj->IsNull()); |
| 3524 LookupResult result; | 3509 LookupResult result; |
| 3525 obj->LocalLookupRealNamedProperty(name, &result); | 3510 obj->LocalLookupRealNamedProperty(name, &result); |
| 3526 | 3511 |
| 3527 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 3512 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
| 3528 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION | 3513 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION |
| 3529 // delete it to avoid running into trouble in DefineAccessor, which | 3514 // delete it to avoid running into trouble in DefineAccessor, which |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3565 // Normalize the elements to enable attributes on the property. | 3550 // Normalize the elements to enable attributes on the property. |
| 3566 NormalizeElements(js_object); | 3551 NormalizeElements(js_object); |
| 3567 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); | 3552 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
| 3568 // Make sure that we never go back to fast case. | 3553 // Make sure that we never go back to fast case. |
| 3569 dictionary->set_requires_slow_elements(); | 3554 dictionary->set_requires_slow_elements(); |
| 3570 PropertyDetails details = PropertyDetails(attr, NORMAL); | 3555 PropertyDetails details = PropertyDetails(attr, NORMAL); |
| 3571 NumberDictionarySet(dictionary, index, obj_value, details); | 3556 NumberDictionarySet(dictionary, index, obj_value, details); |
| 3572 } | 3557 } |
| 3573 | 3558 |
| 3574 LookupResult result; | 3559 LookupResult result; |
| 3575 js_object->LocalLookupRealNamedProperty(*name, &result); | 3560 js_object->LookupRealNamedProperty(*name, &result); |
| 3576 | 3561 |
| 3577 // Take special care when attributes are different and there is already | 3562 // Take special care when attributes are different and there is already |
| 3578 // a property. For simplicity we normalize the property which enables us | 3563 // a property. For simplicity we normalize the property which enables us |
| 3579 // to not worry about changing the instance_descriptor and creating a new | 3564 // to not worry about changing the instance_descriptor and creating a new |
| 3580 // map. The current version of SetObjectProperty does not handle attributes | 3565 // map. The current version of SetObjectProperty does not handle attributes |
| 3581 // correctly in the case where a property is a field and is reset with | 3566 // correctly in the case where a property is a field and is reset with |
| 3582 // new attributes. | 3567 // new attributes. |
| 3583 if (result.IsProperty() && attr != result.GetAttributes()) { | 3568 if (result.IsProperty() && |
| 3569 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { |
| 3584 // New attributes - normalize to avoid writing to instance descriptor | 3570 // New attributes - normalize to avoid writing to instance descriptor |
| 3585 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 3571 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
| 3586 // Use IgnoreAttributes version since a readonly property may be | 3572 // Use IgnoreAttributes version since a readonly property may be |
| 3587 // overridden and SetProperty does not allow this. | 3573 // overridden and SetProperty does not allow this. |
| 3588 return js_object->IgnoreAttributesAndSetLocalProperty(*name, | 3574 return js_object->IgnoreAttributesAndSetLocalProperty(*name, |
| 3589 *obj_value, | 3575 *obj_value, |
| 3590 attr); | 3576 attr); |
| 3591 } | 3577 } |
| 3592 | 3578 |
| 3593 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 3579 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
| (...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6885 function->PrintName(); | 6871 function->PrintName(); |
| 6886 PrintF("]\n"); | 6872 PrintF("]\n"); |
| 6887 } | 6873 } |
| 6888 | 6874 |
| 6889 // Try to compile the optimized code. A true return value from | 6875 // Try to compile the optimized code. A true return value from |
| 6890 // CompileOptimized means that compilation succeeded, not necessarily | 6876 // CompileOptimized means that compilation succeeded, not necessarily |
| 6891 // that optimization succeeded. | 6877 // that optimization succeeded. |
| 6892 if (CompileOptimized(function, ast_id) && function->IsOptimized()) { | 6878 if (CompileOptimized(function, ast_id) && function->IsOptimized()) { |
| 6893 DeoptimizationInputData* data = DeoptimizationInputData::cast( | 6879 DeoptimizationInputData* data = DeoptimizationInputData::cast( |
| 6894 function->code()->deoptimization_data()); | 6880 function->code()->deoptimization_data()); |
| 6895 if (FLAG_trace_osr) { | 6881 if (data->OsrPcOffset()->value() >= 0) { |
| 6896 PrintF("[on-stack replacement offset %d in optimized code]\n", | 6882 if (FLAG_trace_osr) { |
| 6883 PrintF("[on-stack replacement offset %d in optimized code]\n", |
| 6897 data->OsrPcOffset()->value()); | 6884 data->OsrPcOffset()->value()); |
| 6885 } |
| 6886 ASSERT(data->OsrAstId()->value() == ast_id); |
| 6887 } else { |
| 6888 // We may never generate the desired OSR entry if we emit an |
| 6889 // early deoptimize. |
| 6890 succeeded = false; |
| 6898 } | 6891 } |
| 6899 ASSERT(data->OsrAstId()->value() == ast_id); | |
| 6900 ASSERT(data->OsrPcOffset()->value() >= 0); | |
| 6901 } else { | 6892 } else { |
| 6902 succeeded = false; | 6893 succeeded = false; |
| 6903 } | 6894 } |
| 6904 } | 6895 } |
| 6905 | 6896 |
| 6906 // Revert to the original stack checks in the original unoptimized code. | 6897 // Revert to the original stack checks in the original unoptimized code. |
| 6907 if (FLAG_trace_osr) { | 6898 if (FLAG_trace_osr) { |
| 6908 PrintF("[restoring original stack checks in "); | 6899 PrintF("[restoring original stack checks in "); |
| 6909 function->PrintName(); | 6900 function->PrintName(); |
| 6910 PrintF("]\n"); | 6901 PrintF("]\n"); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7206 // The property was not found. It needs to be stored in the global context. | 7197 // The property was not found. It needs to be stored in the global context. |
| 7207 ASSERT(attributes == ABSENT); | 7198 ASSERT(attributes == ABSENT); |
| 7208 attributes = NONE; | 7199 attributes = NONE; |
| 7209 context_ext = Handle<JSObject>(Top::context()->global()); | 7200 context_ext = Handle<JSObject>(Top::context()->global()); |
| 7210 } | 7201 } |
| 7211 | 7202 |
| 7212 // Set the property, but ignore if read_only variable on the context | 7203 // Set the property, but ignore if read_only variable on the context |
| 7213 // extension object itself. | 7204 // extension object itself. |
| 7214 if ((attributes & READ_ONLY) == 0 || | 7205 if ((attributes & READ_ONLY) == 0 || |
| 7215 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { | 7206 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { |
| 7216 Handle<Object> set = SetProperty(context_ext, name, value, attributes); | 7207 Handle<Object> set = SetProperty(context_ext, name, value, NONE); |
| 7217 if (set.is_null()) { | 7208 if (set.is_null()) { |
| 7218 // Failure::Exception is converted to a null handle in the | 7209 // Failure::Exception is converted to a null handle in the |
| 7219 // handle-based methods such as SetProperty. We therefore need | 7210 // handle-based methods such as SetProperty. We therefore need |
| 7220 // to convert null handles back to exceptions. | 7211 // to convert null handles back to exceptions. |
| 7221 ASSERT(Top::has_pending_exception()); | 7212 ASSERT(Top::has_pending_exception()); |
| 7222 return Failure::Exception(); | 7213 return Failure::Exception(); |
| 7223 } | 7214 } |
| 7224 } | 7215 } |
| 7225 return *value; | 7216 return *value; |
| 7226 } | 7217 } |
| (...skipping 3578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10805 } else { | 10796 } else { |
| 10806 // Handle last resort GC and make sure to allow future allocations | 10797 // Handle last resort GC and make sure to allow future allocations |
| 10807 // to grow the heap without causing GCs (if possible). | 10798 // to grow the heap without causing GCs (if possible). |
| 10808 Counters::gc_last_resort_from_js.Increment(); | 10799 Counters::gc_last_resort_from_js.Increment(); |
| 10809 Heap::CollectAllGarbage(false); | 10800 Heap::CollectAllGarbage(false); |
| 10810 } | 10801 } |
| 10811 } | 10802 } |
| 10812 | 10803 |
| 10813 | 10804 |
| 10814 } } // namespace v8::internal | 10805 } } // namespace v8::internal |
| OLD | NEW |