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" |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 Handle<Object> result; | 655 Handle<Object> result; |
656 ASSIGN_RETURN_ON_EXCEPTION( | 656 ASSIGN_RETURN_ON_EXCEPTION( |
657 isolate(), result, | 657 isolate(), result, |
658 Runtime::GetElementOrCharAt(isolate(), object, index), Object); | 658 Runtime::GetElementOrCharAt(isolate(), object, index), Object); |
659 return result; | 659 return result; |
660 } | 660 } |
661 | 661 |
662 bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic; | 662 bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic; |
663 | 663 |
664 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { | 664 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { |
665 // Look up in global context table. | 665 // Look up in script context table. |
666 Handle<String> str_name = Handle<String>::cast(name); | 666 Handle<String> str_name = Handle<String>::cast(name); |
667 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); | 667 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); |
668 Handle<GlobalContextTable> global_contexts( | 668 Handle<ScriptContextTable> script_contexts( |
669 global->native_context()->global_context_table()); | 669 global->native_context()->script_context_table()); |
670 | 670 |
671 GlobalContextTable::LookupResult lookup_result; | 671 ScriptContextTable::LookupResult lookup_result; |
672 if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) { | 672 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { |
673 if (use_ic && LoadGlobalContextFieldStub::Accepted(&lookup_result)) { | 673 if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) { |
674 LoadGlobalContextFieldStub stub(isolate(), &lookup_result); | 674 LoadScriptContextFieldStub stub(isolate(), &lookup_result); |
675 PatchCache(name, stub.GetCode()); | 675 PatchCache(name, stub.GetCode()); |
676 } | 676 } |
677 return FixedArray::get(GlobalContextTable::GetContext( | 677 return FixedArray::get(ScriptContextTable::GetContext( |
678 global_contexts, lookup_result.context_index), | 678 script_contexts, lookup_result.context_index), |
679 lookup_result.slot_index); | 679 lookup_result.slot_index); |
680 } | 680 } |
681 } | 681 } |
682 | 682 |
683 // Named lookup in the object. | 683 // Named lookup in the object. |
684 LookupIterator it(object, name); | 684 LookupIterator it(object, name); |
685 LookupForRead(&it); | 685 LookupForRead(&it); |
686 | 686 |
687 if (it.IsFound() || !IsUndeclaredGlobal(object)) { | 687 if (it.IsFound() || !IsUndeclaredGlobal(object)) { |
688 // Update inline cache and stub cache. | 688 // Update inline cache and stub cache. |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 | 1376 |
1377 it->PrepareTransitionToDataProperty(value, NONE, store_mode); | 1377 it->PrepareTransitionToDataProperty(value, NONE, store_mode); |
1378 return it->IsCacheableTransition(); | 1378 return it->IsCacheableTransition(); |
1379 } | 1379 } |
1380 | 1380 |
1381 | 1381 |
1382 MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, | 1382 MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, |
1383 Handle<Object> value, | 1383 Handle<Object> value, |
1384 JSReceiver::StoreFromKeyed store_mode) { | 1384 JSReceiver::StoreFromKeyed store_mode) { |
1385 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { | 1385 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { |
1386 // Look up in global context table. | 1386 // Look up in script context table. |
1387 Handle<String> str_name = Handle<String>::cast(name); | 1387 Handle<String> str_name = Handle<String>::cast(name); |
1388 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); | 1388 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); |
1389 Handle<GlobalContextTable> global_contexts( | 1389 Handle<ScriptContextTable> script_contexts( |
1390 global->native_context()->global_context_table()); | 1390 global->native_context()->script_context_table()); |
1391 | 1391 |
1392 GlobalContextTable::LookupResult lookup_result; | 1392 ScriptContextTable::LookupResult lookup_result; |
1393 if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) { | 1393 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { |
1394 Handle<Context> global_context = GlobalContextTable::GetContext( | 1394 Handle<Context> script_context = ScriptContextTable::GetContext( |
1395 global_contexts, lookup_result.context_index); | 1395 script_contexts, lookup_result.context_index); |
1396 if (lookup_result.mode == CONST) { | 1396 if (lookup_result.mode == CONST) { |
1397 return TypeError("harmony_const_assign", object, name); | 1397 return TypeError("harmony_const_assign", object, name); |
1398 } | 1398 } |
1399 | 1399 |
1400 if (FLAG_use_ic && | 1400 if (FLAG_use_ic && |
1401 StoreGlobalContextFieldStub::Accepted(&lookup_result)) { | 1401 StoreScriptContextFieldStub::Accepted(&lookup_result)) { |
1402 StoreGlobalContextFieldStub stub(isolate(), &lookup_result); | 1402 StoreScriptContextFieldStub stub(isolate(), &lookup_result); |
1403 PatchCache(name, stub.GetCode()); | 1403 PatchCache(name, stub.GetCode()); |
1404 } | 1404 } |
1405 | 1405 |
1406 global_context->set(lookup_result.slot_index, *value); | 1406 script_context->set(lookup_result.slot_index, *value); |
1407 return value; | 1407 return value; |
1408 } | 1408 } |
1409 } | 1409 } |
1410 | 1410 |
1411 // TODO(verwaest): Let SetProperty do the migration, since storing a property | 1411 // TODO(verwaest): Let SetProperty do the migration, since storing a property |
1412 // might deprecate the current map again, if value does not fit. | 1412 // might deprecate the current map again, if value does not fit. |
1413 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1413 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
1414 Handle<Object> result; | 1414 Handle<Object> result; |
1415 ASSIGN_RETURN_ON_EXCEPTION( | 1415 ASSIGN_RETURN_ON_EXCEPTION( |
1416 isolate(), result, | 1416 isolate(), result, |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 static const Address IC_utilities[] = { | 2781 static const Address IC_utilities[] = { |
2782 #define ADDR(name) FUNCTION_ADDR(name), | 2782 #define ADDR(name) FUNCTION_ADDR(name), |
2783 IC_UTIL_LIST(ADDR) NULL | 2783 IC_UTIL_LIST(ADDR) NULL |
2784 #undef ADDR | 2784 #undef ADDR |
2785 }; | 2785 }; |
2786 | 2786 |
2787 | 2787 |
2788 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2788 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
2789 } | 2789 } |
2790 } // namespace v8::internal | 2790 } // namespace v8::internal |
OLD | NEW |