OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 621 } |
622 | 622 |
623 | 623 |
624 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { | 624 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { |
625 HandleScope scope(isolate); | 625 HandleScope scope(isolate); |
626 ASSERT(args.length() == 1); | 626 ASSERT(args.length() == 1); |
627 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 627 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
628 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | 628 Handle<JSObject> registry = isolate->GetSymbolRegistry(); |
629 Handle<String> part = isolate->factory()->private_intern_string(); | 629 Handle<String> part = isolate->factory()->private_intern_string(); |
630 Handle<JSObject> privates = | 630 Handle<JSObject> privates = |
631 Handle<JSObject>::cast(JSObject::GetProperty(registry, part)); | 631 Handle<JSObject>::cast(Object::GetPropertyOrElement(registry, part)); |
632 Handle<Object> symbol = JSObject::GetProperty(privates, name); | 632 Handle<Object> symbol = Object::GetPropertyOrElement(privates, name); |
633 if (!symbol->IsSymbol()) { | 633 if (!symbol->IsSymbol()) { |
634 ASSERT(symbol->IsUndefined()); | 634 ASSERT(symbol->IsUndefined()); |
635 symbol = isolate->factory()->NewPrivateSymbol(); | 635 symbol = isolate->factory()->NewPrivateSymbol(); |
636 Handle<Symbol>::cast(symbol)->set_name(*name); | 636 Handle<Symbol>::cast(symbol)->set_name(*name); |
637 JSObject::SetProperty(privates, name, symbol, NONE, STRICT); | 637 JSObject::SetProperty(privates, name, symbol, NONE, STRICT); |
638 } | 638 } |
639 return *symbol; | 639 return *symbol; |
640 } | 640 } |
641 | 641 |
642 | 642 |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 ASSERT(!isolate->has_scheduled_exception()); | 1952 ASSERT(!isolate->has_scheduled_exception()); |
1953 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); | 1953 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); |
1954 Handle<AccessorPair> accessors(raw_accessors, isolate); | 1954 Handle<AccessorPair> accessors(raw_accessors, isolate); |
1955 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 1955 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
1956 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1956 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
1957 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1957 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
1958 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); | 1958 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); |
1959 | 1959 |
1960 if (raw_accessors == NULL) { | 1960 if (raw_accessors == NULL) { |
1961 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1961 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
1962 // GetProperty does access check. | 1962 // Runtime::GetObjectProperty does access check. |
1963 Handle<Object> value = GetProperty(isolate, obj, name); | 1963 Handle<Object> value = Runtime::GetObjectProperty(isolate, obj, name); |
1964 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<Object>::null()); | 1964 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<Object>::null()); |
1965 elms->set(VALUE_INDEX, *value); | 1965 elms->set(VALUE_INDEX, *value); |
1966 } else { | 1966 } else { |
1967 // Access checks are performed for both accessors separately. | 1967 // Access checks are performed for both accessors separately. |
1968 // When they fail, the respective field is not set in the descriptor. | 1968 // When they fail, the respective field is not set in the descriptor. |
1969 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); | 1969 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); |
1970 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); | 1970 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); |
1971 | 1971 |
1972 if (!getter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_GET)) { | 1972 if (!getter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_GET)) { |
1973 ASSERT(!isolate->has_scheduled_exception()); | 1973 ASSERT(!isolate->has_scheduled_exception()); |
(...skipping 2999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4973 return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index)); | 4973 return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index)); |
4974 } | 4974 } |
4975 | 4975 |
4976 // Convert the key to a name - possibly by calling back into JavaScript. | 4976 // Convert the key to a name - possibly by calling back into JavaScript. |
4977 Handle<Name> name = ToName(isolate, key); | 4977 Handle<Name> name = ToName(isolate, key); |
4978 RETURN_IF_EMPTY_HANDLE(isolate, name); | 4978 RETURN_IF_EMPTY_HANDLE(isolate, name); |
4979 | 4979 |
4980 return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name)); | 4980 return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name)); |
4981 } | 4981 } |
4982 | 4982 |
4983 MaybeObject* Runtime::GetObjectPropertyOrFail( | |
4984 Isolate* isolate, | |
4985 Handle<Object> object, | |
4986 Handle<Object> key) { | |
4987 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, | |
4988 GetObjectProperty(isolate, object, key)); | |
4989 } | |
4990 | 4983 |
4991 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, | 4984 Handle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
4992 Handle<Object> object, | 4985 Handle<Object> object, |
4993 Handle<Object> key) { | 4986 Handle<Object> key) { |
4994 HandleScope scope(isolate); | |
4995 | |
4996 if (object->IsUndefined() || object->IsNull()) { | 4987 if (object->IsUndefined() || object->IsNull()) { |
4997 Handle<Object> args[2] = { key, object }; | 4988 Handle<Object> args[2] = { key, object }; |
4998 Handle<Object> error = | 4989 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load", |
4999 isolate->factory()->NewTypeError("non_object_property_load", | 4990 HandleVector(args, 2))); |
5000 HandleVector(args, 2)); | 4991 return Handle<Object>(); |
5001 return isolate->Throw(*error); | |
5002 } | 4992 } |
5003 | 4993 |
5004 // Check if the given key is an array index. | 4994 // Check if the given key is an array index. |
5005 uint32_t index; | 4995 uint32_t index; |
5006 if (key->ToArrayIndex(&index)) { | 4996 if (key->ToArrayIndex(&index)) { |
5007 Handle<Object> result = GetElementOrCharAt(isolate, object, index); | 4997 return GetElementOrCharAt(isolate, object, index); |
5008 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
5009 return *result; | |
5010 } | 4998 } |
5011 | 4999 |
5012 // Convert the key to a name - possibly by calling back into JavaScript. | 5000 // Convert the key to a name - possibly by calling back into JavaScript. |
5013 Handle<Name> name = ToName(isolate, key); | 5001 Handle<Name> name = ToName(isolate, key); |
5014 RETURN_IF_EMPTY_HANDLE(isolate, name); | 5002 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, Handle<Object>()); |
5015 | 5003 |
5016 // Check if the name is trivially convertible to an index and get | 5004 // Check if the name is trivially convertible to an index and get |
5017 // the element if so. | 5005 // the element if so. |
5018 if (name->AsArrayIndex(&index)) { | 5006 if (name->AsArrayIndex(&index)) { |
5019 Handle<Object> result = GetElementOrCharAt(isolate, object, index); | 5007 return GetElementOrCharAt(isolate, object, index); |
5020 RETURN_IF_EMPTY_HANDLE(isolate, result); | |
5021 return *result; | |
5022 } else { | 5008 } else { |
5023 return object->GetProperty(*name); | 5009 return Object::GetProperty(object, name); |
5024 } | 5010 } |
5025 } | 5011 } |
5026 | 5012 |
5027 | 5013 |
5028 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 5014 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
5029 SealHandleScope shs(isolate); | 5015 HandleScope scope(isolate); |
5030 ASSERT(args.length() == 2); | 5016 ASSERT(args.length() == 2); |
5031 | 5017 |
5032 Handle<Object> object = args.at<Object>(0); | 5018 Handle<Object> object = args.at<Object>(0); |
5033 Handle<Object> key = args.at<Object>(1); | 5019 Handle<Object> key = args.at<Object>(1); |
5034 | 5020 Handle<Object> result = Runtime::GetObjectProperty(isolate, object, key); |
5035 return Runtime::GetObjectProperty(isolate, object, key); | 5021 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 5022 return *result; |
5036 } | 5023 } |
5037 | 5024 |
5038 | 5025 |
5039 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 5026 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
5040 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 5027 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
5041 SealHandleScope shs(isolate); | 5028 SealHandleScope shs(isolate); |
5042 ASSERT(args.length() == 2); | 5029 ASSERT(args.length() == 2); |
5043 | 5030 |
5044 // Fast cases for getting named properties of the receiver JSObject | 5031 // Fast cases for getting named properties of the receiver JSObject |
5045 // itself. | 5032 // itself. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5128 HandleScope scope(isolate); | 5115 HandleScope scope(isolate); |
5129 Handle<String> str = args.at<String>(0); | 5116 Handle<String> str = args.at<String>(0); |
5130 int index = args.smi_at(1); | 5117 int index = args.smi_at(1); |
5131 if (index >= 0 && index < str->length()) { | 5118 if (index >= 0 && index < str->length()) { |
5132 Handle<Object> result = GetCharAt(str, index); | 5119 Handle<Object> result = GetCharAt(str, index); |
5133 return *result; | 5120 return *result; |
5134 } | 5121 } |
5135 } | 5122 } |
5136 | 5123 |
5137 // Fall back to GetObjectProperty. | 5124 // Fall back to GetObjectProperty. |
5138 return Runtime::GetObjectProperty(isolate, | 5125 HandleScope scope(isolate); |
5139 args.at<Object>(0), | 5126 Handle<Object> result = Runtime::GetObjectProperty( |
5140 args.at<Object>(1)); | 5127 isolate, args.at<Object>(0), args.at<Object>(1)); |
| 5128 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 5129 return *result; |
5141 } | 5130 } |
5142 | 5131 |
5143 | 5132 |
5144 static bool IsValidAccessor(Handle<Object> obj) { | 5133 static bool IsValidAccessor(Handle<Object> obj) { |
5145 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); | 5134 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); |
5146 } | 5135 } |
5147 | 5136 |
5148 | 5137 |
5149 // Implements part of 8.12.9 DefineOwnProperty. | 5138 // Implements part of 8.12.9 DefineOwnProperty. |
5150 // There are 3 cases that lead here: | 5139 // There are 3 cases that lead here: |
(...skipping 6396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11547 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11536 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11548 | 11537 |
11549 // Parameters. | 11538 // Parameters. |
11550 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11539 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11551 // Shadowed parameters were not materialized. | 11540 // Shadowed parameters were not materialized. |
11552 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; | 11541 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; |
11553 | 11542 |
11554 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11543 ASSERT(!frame->GetParameter(i)->IsTheHole()); |
11555 HandleScope scope(isolate); | 11544 HandleScope scope(isolate); |
11556 Handle<String> name(scope_info->ParameterName(i)); | 11545 Handle<String> name(scope_info->ParameterName(i)); |
11557 Handle<Object> value = GetProperty(isolate, target, name); | 11546 Handle<Object> value = Object::GetPropertyOrElement(target, name); |
11558 frame->SetParameterValue(i, *value); | 11547 frame->SetParameterValue(i, *value); |
11559 } | 11548 } |
11560 | 11549 |
11561 // Stack locals. | 11550 // Stack locals. |
11562 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11551 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11563 if (frame->GetExpression(i)->IsTheHole()) continue; | 11552 if (frame->GetExpression(i)->IsTheHole()) continue; |
11564 HandleScope scope(isolate); | 11553 HandleScope scope(isolate); |
11565 Handle<Object> value = GetProperty( | 11554 Handle<Object> value = Object::GetPropertyOrElement( |
11566 isolate, target, Handle<String>(scope_info->StackLocalName(i))); | 11555 target, Handle<String>(scope_info->StackLocalName(i))); |
11567 frame->SetExpression(i, *value); | 11556 frame->SetExpression(i, *value); |
11568 } | 11557 } |
11569 } | 11558 } |
11570 | 11559 |
11571 | 11560 |
11572 static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, | 11561 static Handle<JSObject> MaterializeLocalContext(Isolate* isolate, |
11573 Handle<JSObject> target, | 11562 Handle<JSObject> target, |
11574 Handle<JSFunction> function, | 11563 Handle<JSFunction> function, |
11575 JavaScriptFrame* frame) { | 11564 JavaScriptFrame* frame) { |
11576 HandleScope scope(isolate); | 11565 HandleScope scope(isolate); |
(...skipping 23 matching lines...) Expand all Loading... |
11600 | 11589 |
11601 for (int i = 0; i < keys->length(); i++) { | 11590 for (int i = 0; i < keys->length(); i++) { |
11602 // Names of variables introduced by eval are strings. | 11591 // Names of variables introduced by eval are strings. |
11603 ASSERT(keys->get(i)->IsString()); | 11592 ASSERT(keys->get(i)->IsString()); |
11604 Handle<String> key(String::cast(keys->get(i))); | 11593 Handle<String> key(String::cast(keys->get(i))); |
11605 RETURN_IF_EMPTY_HANDLE_VALUE( | 11594 RETURN_IF_EMPTY_HANDLE_VALUE( |
11606 isolate, | 11595 isolate, |
11607 Runtime::SetObjectProperty(isolate, | 11596 Runtime::SetObjectProperty(isolate, |
11608 target, | 11597 target, |
11609 key, | 11598 key, |
11610 GetProperty(isolate, ext, key), | 11599 Object::GetPropertyOrElement(ext, key), |
11611 NONE, | 11600 NONE, |
11612 SLOPPY), | 11601 SLOPPY), |
11613 Handle<JSObject>()); | 11602 Handle<JSObject>()); |
11614 } | 11603 } |
11615 } | 11604 } |
11616 } | 11605 } |
11617 | 11606 |
11618 return target; | 11607 return target; |
11619 } | 11608 } |
11620 | 11609 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11750 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11739 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
11751 if (threw) return Handle<JSObject>(); | 11740 if (threw) return Handle<JSObject>(); |
11752 | 11741 |
11753 for (int i = 0; i < keys->length(); i++) { | 11742 for (int i = 0; i < keys->length(); i++) { |
11754 // Names of variables introduced by eval are strings. | 11743 // Names of variables introduced by eval are strings. |
11755 ASSERT(keys->get(i)->IsString()); | 11744 ASSERT(keys->get(i)->IsString()); |
11756 Handle<String> key(String::cast(keys->get(i))); | 11745 Handle<String> key(String::cast(keys->get(i))); |
11757 RETURN_IF_EMPTY_HANDLE_VALUE( | 11746 RETURN_IF_EMPTY_HANDLE_VALUE( |
11758 isolate, | 11747 isolate, |
11759 Runtime::SetObjectProperty(isolate, closure_scope, key, | 11748 Runtime::SetObjectProperty(isolate, closure_scope, key, |
11760 GetProperty(isolate, ext, key), | 11749 Object::GetPropertyOrElement(ext, key), |
11761 NONE, SLOPPY), | 11750 NONE, SLOPPY), |
11762 Handle<JSObject>()); | 11751 Handle<JSObject>()); |
11763 } | 11752 } |
11764 } | 11753 } |
11765 | 11754 |
11766 return closure_scope; | 11755 return closure_scope; |
11767 } | 11756 } |
11768 | 11757 |
11769 | 11758 |
11770 // This method copies structure of MaterializeClosure method above. | 11759 // This method copies structure of MaterializeClosure method above. |
(...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15177 } | 15166 } |
15178 } | 15167 } |
15179 | 15168 |
15180 | 15169 |
15181 void Runtime::OutOfMemory() { | 15170 void Runtime::OutOfMemory() { |
15182 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15171 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15183 UNREACHABLE(); | 15172 UNREACHABLE(); |
15184 } | 15173 } |
15185 | 15174 |
15186 } } // namespace v8::internal | 15175 } } // namespace v8::internal |
OLD | NEW |