OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/conversions.h" | 12 #include "src/conversions.h" |
13 #include "src/execution.h" | 13 #include "src/execution.h" |
14 #include "src/frames-inl.h" | 14 #include "src/frames-inl.h" |
15 #include "src/ic/call-optimization.h" | 15 #include "src/ic/call-optimization.h" |
16 #include "src/ic/handler-compiler.h" | 16 #include "src/ic/handler-compiler.h" |
17 #include "src/ic/ic-inl.h" | 17 #include "src/ic/ic-inl.h" |
18 #include "src/ic/ic-compiler.h" | 18 #include "src/ic/ic-compiler.h" |
19 #include "src/ic/stub-cache.h" | 19 #include "src/ic/stub-cache.h" |
20 #include "src/isolate-inl.h" | 20 #include "src/isolate-inl.h" |
21 #include "src/macro-assembler.h" | 21 #include "src/macro-assembler.h" |
22 #include "src/prototype.h" | 22 #include "src/prototype.h" |
23 #include "src/runtime/runtime.h" | 23 #include "src/runtime/runtime.h" |
24 #include "src/runtime/runtime-utils.h" | |
25 | 24 |
26 namespace v8 { | 25 namespace v8 { |
27 namespace internal { | 26 namespace internal { |
28 | 27 |
29 char IC::TransitionMarkFromState(IC::State state) { | 28 char IC::TransitionMarkFromState(IC::State state) { |
30 switch (state) { | 29 switch (state) { |
31 case UNINITIALIZED: | 30 case UNINITIALIZED: |
32 return '0'; | 31 return '0'; |
33 case PREMONOMORPHIC: | 32 case PREMONOMORPHIC: |
34 return '.'; | 33 return '.'; |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 TRACE_GENERIC_IC(isolate(), "StoreIC", | 1740 TRACE_GENERIC_IC(isolate(), "StoreIC", |
1742 "special data property in prototype chain"); | 1741 "special data property in prototype chain"); |
1743 break; | 1742 break; |
1744 } | 1743 } |
1745 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, | 1744 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, |
1746 receiver_map())) { | 1745 receiver_map())) { |
1747 TRACE_GENERIC_IC(isolate(), "StoreIC", "incompatible receiver type"); | 1746 TRACE_GENERIC_IC(isolate(), "StoreIC", "incompatible receiver type"); |
1748 break; | 1747 break; |
1749 } | 1748 } |
1750 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); | 1749 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); |
1751 return compiler.CompileStoreCallback(receiver, lookup->name(), info, | 1750 return compiler.CompileStoreCallback(receiver, lookup->name(), info); |
1752 language_mode()); | |
1753 } else if (accessors->IsAccessorPair()) { | 1751 } else if (accessors->IsAccessorPair()) { |
1754 Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(), | 1752 Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(), |
1755 isolate()); | 1753 isolate()); |
1756 if (!setter->IsJSFunction()) { | 1754 if (!setter->IsJSFunction()) { |
1757 TRACE_GENERIC_IC(isolate(), "StoreIC", "setter not a function"); | 1755 TRACE_GENERIC_IC(isolate(), "StoreIC", "setter not a function"); |
1758 break; | 1756 break; |
1759 } | 1757 } |
1760 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); | 1758 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); |
1761 CallOptimization call_optimization(function); | 1759 CallOptimization call_optimization(function); |
1762 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); | 1760 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2808 return *ic.ToBoolean(object); | 2806 return *ic.ToBoolean(object); |
2809 } | 2807 } |
2810 | 2808 |
2811 | 2809 |
2812 RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) { | 2810 RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) { |
2813 Handle<JSObject> receiver = args.at<JSObject>(0); | 2811 Handle<JSObject> receiver = args.at<JSObject>(0); |
2814 Handle<JSObject> holder = args.at<JSObject>(1); | 2812 Handle<JSObject> holder = args.at<JSObject>(1); |
2815 Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2); | 2813 Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2); |
2816 Handle<Name> name = args.at<Name>(3); | 2814 Handle<Name> name = args.at<Name>(3); |
2817 Handle<Object> value = args.at<Object>(4); | 2815 Handle<Object> value = args.at<Object>(4); |
2818 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 5); | |
2819 HandleScope scope(isolate); | 2816 HandleScope scope(isolate); |
2820 | 2817 |
2821 Handle<AccessorInfo> callback( | 2818 Handle<AccessorInfo> callback( |
2822 callback_or_cell->IsWeakCell() | 2819 callback_or_cell->IsWeakCell() |
2823 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value()) | 2820 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value()) |
2824 : AccessorInfo::cast(*callback_or_cell)); | 2821 : AccessorInfo::cast(*callback_or_cell)); |
2825 | 2822 |
2826 DCHECK(callback->IsCompatibleReceiver(*receiver)); | 2823 DCHECK(callback->IsCompatibleReceiver(*receiver)); |
2827 | 2824 |
2828 Address setter_address = v8::ToCData<Address>(callback->setter()); | 2825 Address setter_address = v8::ToCData<Address>(callback->setter()); |
2829 v8::AccessorNameSetterCallback fun = | 2826 v8::AccessorNameSetterCallback fun = |
2830 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address); | 2827 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address); |
2831 DCHECK(fun != NULL); | 2828 DCHECK(fun != NULL); |
2832 | 2829 |
2833 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); | 2830 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); |
2834 Object::ShouldThrow should_throw = | |
2835 is_sloppy(language_mode) ? Object::DONT_THROW : Object::THROW_ON_ERROR; | |
2836 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, | 2831 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, |
2837 *holder, should_throw); | 2832 *holder); |
2838 custom_args.Call(fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); | 2833 custom_args.Call(fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); |
2839 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 2834 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
2840 return *value; | 2835 return *value; |
2841 } | 2836 } |
2842 | 2837 |
2843 | 2838 |
2844 /** | 2839 /** |
2845 * Attempts to load a property with an interceptor (which must be present), | 2840 * Attempts to load a property with an interceptor (which must be present), |
2846 * but doesn't search the prototype chain. | 2841 * but doesn't search the prototype chain. |
2847 * | 2842 * |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 KeyedLoadICNexus nexus(vector, vector_slot); | 2969 KeyedLoadICNexus nexus(vector, vector_slot); |
2975 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2970 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2976 ic.UpdateState(receiver, key); | 2971 ic.UpdateState(receiver, key); |
2977 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2972 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
2978 } | 2973 } |
2979 | 2974 |
2980 return *result; | 2975 return *result; |
2981 } | 2976 } |
2982 } // namespace internal | 2977 } // namespace internal |
2983 } // namespace v8 | 2978 } // namespace v8 |
OLD | NEW |