| 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 654 } |
| 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()) { |
| 665 // Look up in global context table. |
| 666 Handle<String> str_name = Handle<String>::cast(name); |
| 667 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); |
| 668 Handle<GlobalContextTable> global_contexts( |
| 669 global->native_context()->global_context_table()); |
| 670 |
| 671 GlobalContextTable::LookupResult lookup_result; |
| 672 if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) { |
| 673 return FixedArray::get(GlobalContextTable::GetContext( |
| 674 global_contexts, lookup_result.context_index), |
| 675 lookup_result.slot_index); |
| 676 } |
| 677 } |
| 678 |
| 664 // Named lookup in the object. | 679 // Named lookup in the object. |
| 665 LookupIterator it(object, name); | 680 LookupIterator it(object, name); |
| 666 LookupForRead(&it); | 681 LookupForRead(&it); |
| 667 | 682 |
| 668 if (it.IsFound() || !IsUndeclaredGlobal(object)) { | 683 if (it.IsFound() || !IsUndeclaredGlobal(object)) { |
| 669 // Update inline cache and stub cache. | 684 // Update inline cache and stub cache. |
| 670 if (use_ic) UpdateCaches(&it); | 685 if (use_ic) UpdateCaches(&it); |
| 671 | 686 |
| 672 // Get the property. | 687 // Get the property. |
| 673 Handle<Object> result; | 688 Handle<Object> result; |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 } | 1371 } |
| 1357 | 1372 |
| 1358 it->PrepareTransitionToDataProperty(value, NONE, store_mode); | 1373 it->PrepareTransitionToDataProperty(value, NONE, store_mode); |
| 1359 return it->IsCacheableTransition(); | 1374 return it->IsCacheableTransition(); |
| 1360 } | 1375 } |
| 1361 | 1376 |
| 1362 | 1377 |
| 1363 MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, | 1378 MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, |
| 1364 Handle<Object> value, | 1379 Handle<Object> value, |
| 1365 JSReceiver::StoreFromKeyed store_mode) { | 1380 JSReceiver::StoreFromKeyed store_mode) { |
| 1381 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { |
| 1382 // Look up in global context table. |
| 1383 Handle<String> str_name = Handle<String>::cast(name); |
| 1384 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); |
| 1385 Handle<GlobalContextTable> global_contexts( |
| 1386 global->native_context()->global_context_table()); |
| 1387 |
| 1388 GlobalContextTable::LookupResult lookup_result; |
| 1389 if (GlobalContextTable::Lookup(global_contexts, str_name, &lookup_result)) { |
| 1390 Handle<Context> global_context = GlobalContextTable::GetContext( |
| 1391 global_contexts, lookup_result.context_index); |
| 1392 if (lookup_result.mode == CONST) { |
| 1393 return TypeError("harmony_const_assign", object, name); |
| 1394 } |
| 1395 global_context->set(lookup_result.slot_index, *value); |
| 1396 return value; |
| 1397 } |
| 1398 } |
| 1399 |
| 1366 // TODO(verwaest): Let SetProperty do the migration, since storing a property | 1400 // TODO(verwaest): Let SetProperty do the migration, since storing a property |
| 1367 // might deprecate the current map again, if value does not fit. | 1401 // might deprecate the current map again, if value does not fit. |
| 1368 if (MigrateDeprecated(object) || object->IsJSProxy()) { | 1402 if (MigrateDeprecated(object) || object->IsJSProxy()) { |
| 1369 Handle<Object> result; | 1403 Handle<Object> result; |
| 1370 ASSIGN_RETURN_ON_EXCEPTION( | 1404 ASSIGN_RETURN_ON_EXCEPTION( |
| 1371 isolate(), result, | 1405 isolate(), result, |
| 1372 Object::SetProperty(object, name, value, strict_mode()), Object); | 1406 Object::SetProperty(object, name, value, strict_mode()), Object); |
| 1373 return result; | 1407 return result; |
| 1374 } | 1408 } |
| 1375 | 1409 |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 static const Address IC_utilities[] = { | 2770 static const Address IC_utilities[] = { |
| 2737 #define ADDR(name) FUNCTION_ADDR(name), | 2771 #define ADDR(name) FUNCTION_ADDR(name), |
| 2738 IC_UTIL_LIST(ADDR) NULL | 2772 IC_UTIL_LIST(ADDR) NULL |
| 2739 #undef ADDR | 2773 #undef ADDR |
| 2740 }; | 2774 }; |
| 2741 | 2775 |
| 2742 | 2776 |
| 2743 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2777 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 2744 } | 2778 } |
| 2745 } // namespace v8::internal | 2779 } // namespace v8::internal |
| OLD | NEW |