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