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/v8.h" | 5 #include "src/v8.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/ic/call-optimization.h" | 14 #include "src/ic/call-optimization.h" |
15 #include "src/ic/handler-compiler.h" | 15 #include "src/ic/handler-compiler.h" |
16 #include "src/ic/ic-inl.h" | 16 #include "src/ic/ic-inl.h" |
17 #include "src/ic/ic-compiler.h" | 17 #include "src/ic/ic-compiler.h" |
18 #include "src/ic/stub-cache.h" | 18 #include "src/ic/stub-cache.h" |
| 19 #include "src/messages.h" |
19 #include "src/prototype.h" | 20 #include "src/prototype.h" |
20 #include "src/runtime/runtime.h" | 21 #include "src/runtime/runtime.h" |
21 | 22 |
22 namespace v8 { | 23 namespace v8 { |
23 namespace internal { | 24 namespace internal { |
24 | 25 |
25 char IC::TransitionMarkFromState(IC::State state) { | 26 char IC::TransitionMarkFromState(IC::State state) { |
26 switch (state) { | 27 switch (state) { |
27 case UNINITIALIZED: | 28 case UNINITIALIZED: |
28 return '0'; | 29 return '0'; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 363 |
363 | 364 |
364 MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object, | 365 MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object, |
365 Handle<Object> key) { | 366 Handle<Object> key) { |
366 HandleScope scope(isolate()); | 367 HandleScope scope(isolate()); |
367 Handle<Object> args[2] = {key, object}; | 368 Handle<Object> args[2] = {key, object}; |
368 THROW_NEW_ERROR(isolate(), NewTypeError(type, HandleVector(args, 2)), Object); | 369 THROW_NEW_ERROR(isolate(), NewTypeError(type, HandleVector(args, 2)), Object); |
369 } | 370 } |
370 | 371 |
371 | 372 |
372 MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<Name> name) { | 373 MaybeHandle<Object> IC::ReferenceError(Handle<Name> name) { |
373 HandleScope scope(isolate()); | 374 HandleScope scope(isolate()); |
374 THROW_NEW_ERROR(isolate(), NewReferenceError(type, HandleVector(&name, 1)), | 375 THROW_NEW_ERROR( |
375 Object); | 376 isolate(), NewReferenceError(MessageTemplate::kNotDefined, name), Object); |
376 } | 377 } |
377 | 378 |
378 | 379 |
379 static void ComputeTypeInfoCountDelta(IC::State old_state, IC::State new_state, | 380 static void ComputeTypeInfoCountDelta(IC::State old_state, IC::State new_state, |
380 int* polymorphic_delta, | 381 int* polymorphic_delta, |
381 int* generic_delta) { | 382 int* generic_delta) { |
382 switch (old_state) { | 383 switch (old_state) { |
383 case UNINITIALIZED: | 384 case UNINITIALIZED: |
384 case PREMONOMORPHIC: | 385 case PREMONOMORPHIC: |
385 if (new_state == UNINITIALIZED || new_state == PREMONOMORPHIC) break; | 386 if (new_state == UNINITIALIZED || new_state == PREMONOMORPHIC) break; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 731 |
731 ScriptContextTable::LookupResult lookup_result; | 732 ScriptContextTable::LookupResult lookup_result; |
732 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { | 733 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { |
733 Handle<Object> result = | 734 Handle<Object> result = |
734 FixedArray::get(ScriptContextTable::GetContext( | 735 FixedArray::get(ScriptContextTable::GetContext( |
735 script_contexts, lookup_result.context_index), | 736 script_contexts, lookup_result.context_index), |
736 lookup_result.slot_index); | 737 lookup_result.slot_index); |
737 if (*result == *isolate()->factory()->the_hole_value()) { | 738 if (*result == *isolate()->factory()->the_hole_value()) { |
738 // Do not install stubs and stay pre-monomorphic for | 739 // Do not install stubs and stay pre-monomorphic for |
739 // uninitialized accesses. | 740 // uninitialized accesses. |
740 return ReferenceError("not_defined", name); | 741 return ReferenceError(name); |
741 } | 742 } |
742 | 743 |
743 if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) { | 744 if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) { |
744 LoadScriptContextFieldStub stub(isolate(), &lookup_result); | 745 LoadScriptContextFieldStub stub(isolate(), &lookup_result); |
745 PatchCache(name, stub.GetCode()); | 746 PatchCache(name, stub.GetCode()); |
746 } | 747 } |
747 return result; | 748 return result; |
748 } | 749 } |
749 } | 750 } |
750 | 751 |
751 // Named lookup in the object. | 752 // Named lookup in the object. |
752 LookupIterator it(object, name); | 753 LookupIterator it(object, name); |
753 LookupForRead(&it); | 754 LookupForRead(&it); |
754 | 755 |
755 if (it.IsFound() || !IsUndeclaredGlobal(object)) { | 756 if (it.IsFound() || !IsUndeclaredGlobal(object)) { |
756 // Update inline cache and stub cache. | 757 // Update inline cache and stub cache. |
757 if (use_ic) UpdateCaches(&it); | 758 if (use_ic) UpdateCaches(&it); |
758 | 759 |
759 // Get the property. | 760 // Get the property. |
760 Handle<Object> result; | 761 Handle<Object> result; |
761 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it), | 762 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it), |
762 Object); | 763 Object); |
763 if (it.IsFound()) { | 764 if (it.IsFound()) { |
764 return result; | 765 return result; |
765 } else if (!IsUndeclaredGlobal(object)) { | 766 } else if (!IsUndeclaredGlobal(object)) { |
766 LOG(isolate(), SuspectReadEvent(*name, *object)); | 767 LOG(isolate(), SuspectReadEvent(*name, *object)); |
767 return result; | 768 return result; |
768 } | 769 } |
769 } | 770 } |
770 return ReferenceError("not_defined", name); | 771 return ReferenceError(name); |
771 } | 772 } |
772 | 773 |
773 | 774 |
774 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, | 775 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, |
775 Handle<Map> new_receiver_map) { | 776 Handle<Map> new_receiver_map) { |
776 DCHECK(!new_receiver_map.is_null()); | 777 DCHECK(!new_receiver_map.is_null()); |
777 for (int current = 0; current < receiver_maps->length(); ++current) { | 778 for (int current = 0; current < receiver_maps->length(); ++current) { |
778 if (!receiver_maps->at(current).is_null() && | 779 if (!receiver_maps->at(current).is_null() && |
779 receiver_maps->at(current).is_identical_to(new_receiver_map)) { | 780 receiver_maps->at(current).is_identical_to(new_receiver_map)) { |
780 return false; | 781 return false; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 if (lookup_result.mode == CONST) { | 1560 if (lookup_result.mode == CONST) { |
1560 return TypeError("const_assign", object, name); | 1561 return TypeError("const_assign", object, name); |
1561 } | 1562 } |
1562 | 1563 |
1563 Handle<Object> previous_value = | 1564 Handle<Object> previous_value = |
1564 FixedArray::get(script_context, lookup_result.slot_index); | 1565 FixedArray::get(script_context, lookup_result.slot_index); |
1565 | 1566 |
1566 if (*previous_value == *isolate()->factory()->the_hole_value()) { | 1567 if (*previous_value == *isolate()->factory()->the_hole_value()) { |
1567 // Do not install stubs and stay pre-monomorphic for | 1568 // Do not install stubs and stay pre-monomorphic for |
1568 // uninitialized accesses. | 1569 // uninitialized accesses. |
1569 return ReferenceError("not_defined", name); | 1570 return ReferenceError(name); |
1570 } | 1571 } |
1571 | 1572 |
1572 if (FLAG_use_ic && | 1573 if (FLAG_use_ic && |
1573 StoreScriptContextFieldStub::Accepted(&lookup_result)) { | 1574 StoreScriptContextFieldStub::Accepted(&lookup_result)) { |
1574 StoreScriptContextFieldStub stub(isolate(), &lookup_result); | 1575 StoreScriptContextFieldStub stub(isolate(), &lookup_result); |
1575 PatchCache(name, stub.GetCode()); | 1576 PatchCache(name, stub.GetCode()); |
1576 } | 1577 } |
1577 | 1578 |
1578 script_context->set(lookup_result.slot_index, *value); | 1579 script_context->set(lookup_result.slot_index, *value); |
1579 return value; | 1580 return value; |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 // Note that both keyed and non-keyed loads may end up here. | 2931 // Note that both keyed and non-keyed loads may end up here. |
2931 HandleScope scope(isolate); | 2932 HandleScope scope(isolate); |
2932 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true); | 2933 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true); |
2933 if (ic.contextual_mode() != CONTEXTUAL) { | 2934 if (ic.contextual_mode() != CONTEXTUAL) { |
2934 return isolate->heap()->undefined_value(); | 2935 return isolate->heap()->undefined_value(); |
2935 } | 2936 } |
2936 | 2937 |
2937 // Throw a reference error. | 2938 // Throw a reference error. |
2938 Handle<Name> name_handle(name); | 2939 Handle<Name> name_handle(name); |
2939 THROW_NEW_ERROR_RETURN_FAILURE( | 2940 THROW_NEW_ERROR_RETURN_FAILURE( |
2940 isolate, NewReferenceError("not_defined", HandleVector(&name_handle, 1))); | 2941 isolate, NewReferenceError(MessageTemplate::kNotDefined, name_handle)); |
2941 } | 2942 } |
2942 | 2943 |
2943 | 2944 |
2944 /** | 2945 /** |
2945 * Loads a property with an interceptor performing post interceptor | 2946 * Loads a property with an interceptor performing post interceptor |
2946 * lookup if interceptor failed. | 2947 * lookup if interceptor failed. |
2947 */ | 2948 */ |
2948 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { | 2949 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { |
2949 HandleScope scope(isolate); | 2950 HandleScope scope(isolate); |
2950 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 2951 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3051 static const Address IC_utilities[] = { | 3052 static const Address IC_utilities[] = { |
3052 #define ADDR(name) FUNCTION_ADDR(name), | 3053 #define ADDR(name) FUNCTION_ADDR(name), |
3053 IC_UTIL_LIST(ADDR) NULL | 3054 IC_UTIL_LIST(ADDR) NULL |
3054 #undef ADDR | 3055 #undef ADDR |
3055 }; | 3056 }; |
3056 | 3057 |
3057 | 3058 |
3058 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3059 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3059 } | 3060 } |
3060 } // namespace v8::internal | 3061 } // namespace v8::internal |
OLD | NEW |