| 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" | |
| 20 #include "src/prototype.h" | 19 #include "src/prototype.h" |
| 21 #include "src/runtime/runtime.h" | 20 #include "src/runtime/runtime.h" |
| 22 | 21 |
| 23 namespace v8 { | 22 namespace v8 { |
| 24 namespace internal { | 23 namespace internal { |
| 25 | 24 |
| 26 char IC::TransitionMarkFromState(IC::State state) { | 25 char IC::TransitionMarkFromState(IC::State state) { |
| 27 switch (state) { | 26 switch (state) { |
| 28 case UNINITIALIZED: | 27 case UNINITIALIZED: |
| 29 return '0'; | 28 return '0'; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // The builtins object is special. It only changes when JavaScript | 354 // The builtins object is special. It only changes when JavaScript |
| 356 // builtins are loaded lazily. It is important to keep inline | 355 // builtins are loaded lazily. It is important to keep inline |
| 357 // caches for the builtins object monomorphic. Therefore, if we get | 356 // caches for the builtins object monomorphic. Therefore, if we get |
| 358 // an inline cache miss for the builtins object after lazily loading | 357 // an inline cache miss for the builtins object after lazily loading |
| 359 // JavaScript builtins, we return uninitialized as the state to | 358 // JavaScript builtins, we return uninitialized as the state to |
| 360 // force the inline cache back to monomorphic state. | 359 // force the inline cache back to monomorphic state. |
| 361 if (receiver->IsJSBuiltinsObject()) state_ = PREMONOMORPHIC; | 360 if (receiver->IsJSBuiltinsObject()) state_ = PREMONOMORPHIC; |
| 362 } | 361 } |
| 363 | 362 |
| 364 | 363 |
| 365 MaybeHandle<Object> IC::TypeError(const char* type, Handle<Object> object, | 364 MaybeHandle<Object> IC::TypeError(MessageTemplate::Template index, |
| 366 Handle<Object> key) { | 365 Handle<Object> object, Handle<Object> key) { |
| 367 HandleScope scope(isolate()); | 366 HandleScope scope(isolate()); |
| 368 Handle<Object> args[2] = {key, object}; | 367 THROW_NEW_ERROR(isolate(), NewTypeError(index, key, object), Object); |
| 369 THROW_NEW_ERROR(isolate(), NewTypeError(type, HandleVector(args, 2)), Object); | |
| 370 } | 368 } |
| 371 | 369 |
| 372 | 370 |
| 373 MaybeHandle<Object> IC::ReferenceError(Handle<Name> name) { | 371 MaybeHandle<Object> IC::ReferenceError(Handle<Name> name) { |
| 374 HandleScope scope(isolate()); | 372 HandleScope scope(isolate()); |
| 375 THROW_NEW_ERROR( | 373 THROW_NEW_ERROR( |
| 376 isolate(), NewReferenceError(MessageTemplate::kNotDefined, name), Object); | 374 isolate(), NewReferenceError(MessageTemplate::kNotDefined, name), Object); |
| 377 } | 375 } |
| 378 | 376 |
| 379 | 377 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 vector_set_ = true; | 687 vector_set_ = true; |
| 690 OnTypeFeedbackChanged(isolate(), get_host(), *vector(), saved_state(), | 688 OnTypeFeedbackChanged(isolate(), get_host(), *vector(), saved_state(), |
| 691 POLYMORPHIC); | 689 POLYMORPHIC); |
| 692 } | 690 } |
| 693 | 691 |
| 694 | 692 |
| 695 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { | 693 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) { |
| 696 // If the object is undefined or null it's illegal to try to get any | 694 // If the object is undefined or null it's illegal to try to get any |
| 697 // of its properties; throw a TypeError in that case. | 695 // of its properties; throw a TypeError in that case. |
| 698 if (object->IsUndefined() || object->IsNull()) { | 696 if (object->IsUndefined() || object->IsNull()) { |
| 699 return TypeError("non_object_property_load", object, name); | 697 return TypeError(MessageTemplate::kNonObjectPropertyLoad, object, name); |
| 700 } | 698 } |
| 701 | 699 |
| 702 // Check if the name is trivially convertible to an index and get | 700 // Check if the name is trivially convertible to an index and get |
| 703 // the element or char if so. | 701 // the element or char if so. |
| 704 uint32_t index; | 702 uint32_t index; |
| 705 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 703 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
| 706 // Rewrite to the generic keyed load stub. | 704 // Rewrite to the generic keyed load stub. |
| 707 if (FLAG_use_ic) { | 705 if (FLAG_use_ic) { |
| 708 if (UseVector()) { | 706 if (UseVector()) { |
| 709 ConfigureVectorState(MEGAMORPHIC); | 707 ConfigureVectorState(MEGAMORPHIC); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 Handle<String> str_name = Handle<String>::cast(name); | 1549 Handle<String> str_name = Handle<String>::cast(name); |
| 1552 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); | 1550 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); |
| 1553 Handle<ScriptContextTable> script_contexts( | 1551 Handle<ScriptContextTable> script_contexts( |
| 1554 global->native_context()->script_context_table()); | 1552 global->native_context()->script_context_table()); |
| 1555 | 1553 |
| 1556 ScriptContextTable::LookupResult lookup_result; | 1554 ScriptContextTable::LookupResult lookup_result; |
| 1557 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { | 1555 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { |
| 1558 Handle<Context> script_context = ScriptContextTable::GetContext( | 1556 Handle<Context> script_context = ScriptContextTable::GetContext( |
| 1559 script_contexts, lookup_result.context_index); | 1557 script_contexts, lookup_result.context_index); |
| 1560 if (lookup_result.mode == CONST) { | 1558 if (lookup_result.mode == CONST) { |
| 1561 return TypeError("const_assign", object, name); | 1559 return TypeError(MessageTemplate::kConstAssign, object, name); |
| 1562 } | 1560 } |
| 1563 | 1561 |
| 1564 Handle<Object> previous_value = | 1562 Handle<Object> previous_value = |
| 1565 FixedArray::get(script_context, lookup_result.slot_index); | 1563 FixedArray::get(script_context, lookup_result.slot_index); |
| 1566 | 1564 |
| 1567 if (*previous_value == *isolate()->factory()->the_hole_value()) { | 1565 if (*previous_value == *isolate()->factory()->the_hole_value()) { |
| 1568 // Do not install stubs and stay pre-monomorphic for | 1566 // Do not install stubs and stay pre-monomorphic for |
| 1569 // uninitialized accesses. | 1567 // uninitialized accesses. |
| 1570 return ReferenceError(name); | 1568 return ReferenceError(name); |
| 1571 } | 1569 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1587 Handle<Object> result; | 1585 Handle<Object> result; |
| 1588 ASSIGN_RETURN_ON_EXCEPTION( | 1586 ASSIGN_RETURN_ON_EXCEPTION( |
| 1589 isolate(), result, | 1587 isolate(), result, |
| 1590 Object::SetProperty(object, name, value, language_mode()), Object); | 1588 Object::SetProperty(object, name, value, language_mode()), Object); |
| 1591 return result; | 1589 return result; |
| 1592 } | 1590 } |
| 1593 | 1591 |
| 1594 // If the object is undefined or null it's illegal to try to set any | 1592 // If the object is undefined or null it's illegal to try to set any |
| 1595 // properties on it; throw a TypeError in that case. | 1593 // properties on it; throw a TypeError in that case. |
| 1596 if (object->IsUndefined() || object->IsNull()) { | 1594 if (object->IsUndefined() || object->IsNull()) { |
| 1597 return TypeError("non_object_property_store", object, name); | 1595 return TypeError(MessageTemplate::kNonObjectPropertyStore, object, name); |
| 1598 } | 1596 } |
| 1599 | 1597 |
| 1600 // Check if the given name is an array index. | 1598 // Check if the given name is an array index. |
| 1601 uint32_t index; | 1599 uint32_t index; |
| 1602 if (name->AsArrayIndex(&index)) { | 1600 if (name->AsArrayIndex(&index)) { |
| 1603 // Ignore other stores where the receiver is not a JSObject. | 1601 // Ignore other stores where the receiver is not a JSObject. |
| 1604 // TODO(1475): Must check prototype chains of object wrappers. | 1602 // TODO(1475): Must check prototype chains of object wrappers. |
| 1605 if (!object->IsJSObject()) return value; | 1603 if (!object->IsJSObject()) return value; |
| 1606 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1604 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 1607 | 1605 |
| (...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 static const Address IC_utilities[] = { | 3050 static const Address IC_utilities[] = { |
| 3053 #define ADDR(name) FUNCTION_ADDR(name), | 3051 #define ADDR(name) FUNCTION_ADDR(name), |
| 3054 IC_UTIL_LIST(ADDR) NULL | 3052 IC_UTIL_LIST(ADDR) NULL |
| 3055 #undef ADDR | 3053 #undef ADDR |
| 3056 }; | 3054 }; |
| 3057 | 3055 |
| 3058 | 3056 |
| 3059 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3057 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 3060 } | 3058 } |
| 3061 } // namespace v8::internal | 3059 } // namespace v8::internal |
| OLD | NEW |