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" |
24 | 25 |
25 namespace v8 { | 26 namespace v8 { |
26 namespace internal { | 27 namespace internal { |
27 | 28 |
28 char IC::TransitionMarkFromState(IC::State state) { | 29 char IC::TransitionMarkFromState(IC::State state) { |
29 switch (state) { | 30 switch (state) { |
30 case UNINITIALIZED: | 31 case UNINITIALIZED: |
31 return '0'; | 32 return '0'; |
32 case PREMONOMORPHIC: | 33 case PREMONOMORPHIC: |
33 return '.'; | 34 return '.'; |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 TRACE_GENERIC_IC(isolate(), "StoreIC", | 1741 TRACE_GENERIC_IC(isolate(), "StoreIC", |
1741 "special data property in prototype chain"); | 1742 "special data property in prototype chain"); |
1742 break; | 1743 break; |
1743 } | 1744 } |
1744 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, | 1745 if (!AccessorInfo::IsCompatibleReceiverMap(isolate(), info, |
1745 receiver_map())) { | 1746 receiver_map())) { |
1746 TRACE_GENERIC_IC(isolate(), "StoreIC", "incompatible receiver type"); | 1747 TRACE_GENERIC_IC(isolate(), "StoreIC", "incompatible receiver type"); |
1747 break; | 1748 break; |
1748 } | 1749 } |
1749 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); | 1750 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); |
1750 return compiler.CompileStoreCallback(receiver, lookup->name(), info); | 1751 return compiler.CompileStoreCallback(receiver, lookup->name(), info, |
| 1752 language_mode()); |
1751 } else if (accessors->IsAccessorPair()) { | 1753 } else if (accessors->IsAccessorPair()) { |
1752 Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(), | 1754 Handle<Object> setter(Handle<AccessorPair>::cast(accessors)->setter(), |
1753 isolate()); | 1755 isolate()); |
1754 if (!setter->IsJSFunction()) { | 1756 if (!setter->IsJSFunction()) { |
1755 TRACE_GENERIC_IC(isolate(), "StoreIC", "setter not a function"); | 1757 TRACE_GENERIC_IC(isolate(), "StoreIC", "setter not a function"); |
1756 break; | 1758 break; |
1757 } | 1759 } |
1758 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); | 1760 Handle<JSFunction> function = Handle<JSFunction>::cast(setter); |
1759 CallOptimization call_optimization(function); | 1761 CallOptimization call_optimization(function); |
1760 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); | 1762 NamedStoreHandlerCompiler compiler(isolate(), receiver_map(), holder); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 return *ic.ToBoolean(object); | 2808 return *ic.ToBoolean(object); |
2807 } | 2809 } |
2808 | 2810 |
2809 | 2811 |
2810 RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) { | 2812 RUNTIME_FUNCTION(Runtime_StoreCallbackProperty) { |
2811 Handle<JSObject> receiver = args.at<JSObject>(0); | 2813 Handle<JSObject> receiver = args.at<JSObject>(0); |
2812 Handle<JSObject> holder = args.at<JSObject>(1); | 2814 Handle<JSObject> holder = args.at<JSObject>(1); |
2813 Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2); | 2815 Handle<HeapObject> callback_or_cell = args.at<HeapObject>(2); |
2814 Handle<Name> name = args.at<Name>(3); | 2816 Handle<Name> name = args.at<Name>(3); |
2815 Handle<Object> value = args.at<Object>(4); | 2817 Handle<Object> value = args.at<Object>(4); |
| 2818 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 5); |
2816 HandleScope scope(isolate); | 2819 HandleScope scope(isolate); |
2817 | 2820 |
2818 Handle<AccessorInfo> callback( | 2821 Handle<AccessorInfo> callback( |
2819 callback_or_cell->IsWeakCell() | 2822 callback_or_cell->IsWeakCell() |
2820 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value()) | 2823 ? AccessorInfo::cast(WeakCell::cast(*callback_or_cell)->value()) |
2821 : AccessorInfo::cast(*callback_or_cell)); | 2824 : AccessorInfo::cast(*callback_or_cell)); |
2822 | 2825 |
2823 DCHECK(callback->IsCompatibleReceiver(*receiver)); | 2826 DCHECK(callback->IsCompatibleReceiver(*receiver)); |
2824 | 2827 |
2825 Address setter_address = v8::ToCData<Address>(callback->setter()); | 2828 Address setter_address = v8::ToCData<Address>(callback->setter()); |
2826 v8::AccessorNameSetterCallback fun = | 2829 v8::AccessorNameSetterCallback fun = |
2827 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address); | 2830 FUNCTION_CAST<v8::AccessorNameSetterCallback>(setter_address); |
2828 DCHECK(fun != NULL); | 2831 DCHECK(fun != NULL); |
2829 | 2832 |
2830 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); | 2833 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); |
| 2834 Object::ShouldThrow should_throw = |
| 2835 is_sloppy(language_mode) ? Object::DONT_THROW : Object::THROW_ON_ERROR; |
2831 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, | 2836 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, |
2832 *holder); | 2837 *holder, should_throw); |
2833 custom_args.Call(fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); | 2838 custom_args.Call(fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); |
2834 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 2839 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
2835 return *value; | 2840 return *value; |
2836 } | 2841 } |
2837 | 2842 |
2838 | 2843 |
2839 /** | 2844 /** |
2840 * Attempts to load a property with an interceptor (which must be present), | 2845 * Attempts to load a property with an interceptor (which must be present), |
2841 * but doesn't search the prototype chain. | 2846 * but doesn't search the prototype chain. |
2842 * | 2847 * |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2969 KeyedLoadICNexus nexus(vector, vector_slot); | 2974 KeyedLoadICNexus nexus(vector, vector_slot); |
2970 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2975 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2971 ic.UpdateState(receiver, key); | 2976 ic.UpdateState(receiver, key); |
2972 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2977 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
2973 } | 2978 } |
2974 | 2979 |
2975 return *result; | 2980 return *result; |
2976 } | 2981 } |
2977 } // namespace internal | 2982 } // namespace internal |
2978 } // namespace v8 | 2983 } // namespace v8 |
OLD | NEW |