OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 return *hresult; | 1746 return *hresult; |
1747 } | 1747 } |
1748 | 1748 |
1749 | 1749 |
1750 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, | 1750 void JSObject::EnqueueChangeRecord(Handle<JSObject> object, |
1751 const char* type_str, | 1751 const char* type_str, |
1752 Handle<String> name, | 1752 Handle<String> name, |
1753 Handle<Object> old_value) { | 1753 Handle<Object> old_value) { |
1754 Isolate* isolate = object->GetIsolate(); | 1754 Isolate* isolate = object->GetIsolate(); |
1755 HandleScope scope; | 1755 HandleScope scope; |
1756 Handle<String> type = isolate->factory()->LookupAsciiSymbol(type_str); | 1756 Handle<String> type = isolate->factory()->LookupUtf8Symbol(type_str); |
1757 if (object->IsJSGlobalObject()) { | 1757 if (object->IsJSGlobalObject()) { |
1758 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); | 1758 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); |
1759 } | 1759 } |
1760 Handle<Object> args[] = { type, object, name, old_value }; | 1760 Handle<Object> args[] = { type, object, name, old_value }; |
1761 bool threw; | 1761 bool threw; |
1762 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()), | 1762 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()), |
1763 Handle<Object>(isolate->heap()->undefined_value()), | 1763 Handle<Object>(isolate->heap()->undefined_value()), |
1764 old_value->IsTheHole() ? 3 : 4, args, | 1764 old_value->IsTheHole() ? 3 : 4, args, |
1765 &threw); | 1765 &threw); |
1766 ASSERT(!threw); | 1766 ASSERT(!threw); |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2649 | 2649 |
2650 // Emulate [[GetProperty]] semantics for proxies. | 2650 // Emulate [[GetProperty]] semantics for proxies. |
2651 bool has_pending_exception; | 2651 bool has_pending_exception; |
2652 Handle<Object> argv[] = { result }; | 2652 Handle<Object> argv[] = { result }; |
2653 Handle<Object> desc = | 2653 Handle<Object> desc = |
2654 Execution::Call(isolate->to_complete_property_descriptor(), result, | 2654 Execution::Call(isolate->to_complete_property_descriptor(), result, |
2655 ARRAY_SIZE(argv), argv, &has_pending_exception); | 2655 ARRAY_SIZE(argv), argv, &has_pending_exception); |
2656 if (has_pending_exception) return Failure::Exception(); | 2656 if (has_pending_exception) return Failure::Exception(); |
2657 | 2657 |
2658 // [[GetProperty]] requires to check that all properties are configurable. | 2658 // [[GetProperty]] requires to check that all properties are configurable. |
2659 Handle<String> configurable_name = | 2659 Handle<String> configurable_name = isolate->factory()->LookupOneByteSymbol( |
2660 isolate->factory()->LookupAsciiSymbol("configurable_"); | 2660 STATIC_ASCII_VECTOR("configurable_")); |
2661 Handle<Object> configurable( | 2661 Handle<Object> configurable( |
2662 v8::internal::GetProperty(desc, configurable_name)); | 2662 v8::internal::GetProperty(desc, configurable_name)); |
2663 ASSERT(!isolate->has_pending_exception()); | 2663 ASSERT(!isolate->has_pending_exception()); |
2664 ASSERT(configurable->IsTrue() || configurable->IsFalse()); | 2664 ASSERT(configurable->IsTrue() || configurable->IsFalse()); |
2665 if (configurable->IsFalse()) { | 2665 if (configurable->IsFalse()) { |
2666 Handle<String> trap = | 2666 Handle<String> trap = |
2667 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor"); | 2667 isolate->factory()->LookupOneByteSymbol( |
| 2668 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
2668 Handle<Object> args[] = { handler, trap, name }; | 2669 Handle<Object> args[] = { handler, trap, name }; |
2669 Handle<Object> error = isolate->factory()->NewTypeError( | 2670 Handle<Object> error = isolate->factory()->NewTypeError( |
2670 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 2671 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
2671 return isolate->Throw(*error); | 2672 return isolate->Throw(*error); |
2672 } | 2673 } |
2673 ASSERT(configurable->IsTrue()); | 2674 ASSERT(configurable->IsTrue()); |
2674 | 2675 |
2675 // Check for DataDescriptor. | 2676 // Check for DataDescriptor. |
2676 Handle<String> hasWritable_name = | 2677 Handle<String> hasWritable_name = |
2677 isolate->factory()->LookupAsciiSymbol("hasWritable_"); | 2678 isolate->factory()->LookupOneByteSymbol( |
| 2679 STATIC_ASCII_VECTOR("hasWritable_")); |
2678 Handle<Object> hasWritable(v8::internal::GetProperty(desc, hasWritable_name)); | 2680 Handle<Object> hasWritable(v8::internal::GetProperty(desc, hasWritable_name)); |
2679 ASSERT(!isolate->has_pending_exception()); | 2681 ASSERT(!isolate->has_pending_exception()); |
2680 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse()); | 2682 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse()); |
2681 if (hasWritable->IsTrue()) { | 2683 if (hasWritable->IsTrue()) { |
2682 Handle<String> writable_name = | 2684 Handle<String> writable_name = |
2683 isolate->factory()->LookupAsciiSymbol("writable_"); | 2685 isolate->factory()->LookupOneByteSymbol( |
| 2686 STATIC_ASCII_VECTOR("writable_")); |
2684 Handle<Object> writable(v8::internal::GetProperty(desc, writable_name)); | 2687 Handle<Object> writable(v8::internal::GetProperty(desc, writable_name)); |
2685 ASSERT(!isolate->has_pending_exception()); | 2688 ASSERT(!isolate->has_pending_exception()); |
2686 ASSERT(writable->IsTrue() || writable->IsFalse()); | 2689 ASSERT(writable->IsTrue() || writable->IsFalse()); |
2687 *done = writable->IsFalse(); | 2690 *done = writable->IsFalse(); |
2688 if (!*done) return GetHeap()->the_hole_value(); | 2691 if (!*done) return GetHeap()->the_hole_value(); |
2689 if (strict_mode == kNonStrictMode) return *value; | 2692 if (strict_mode == kNonStrictMode) return *value; |
2690 Handle<Object> args[] = { name, receiver }; | 2693 Handle<Object> args[] = { name, receiver }; |
2691 Handle<Object> error = isolate->factory()->NewTypeError( | 2694 Handle<Object> error = isolate->factory()->NewTypeError( |
2692 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))); | 2695 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))); |
2693 return isolate->Throw(*error); | 2696 return isolate->Throw(*error); |
2694 } | 2697 } |
2695 | 2698 |
2696 // We have an AccessorDescriptor. | 2699 // We have an AccessorDescriptor. |
2697 Handle<String> set_name = isolate->factory()->LookupAsciiSymbol("set_"); | 2700 Handle<String> set_name = isolate->factory()->LookupOneByteSymbol( |
| 2701 STATIC_ASCII_VECTOR("set_")); |
2698 Handle<Object> setter(v8::internal::GetProperty(desc, set_name)); | 2702 Handle<Object> setter(v8::internal::GetProperty(desc, set_name)); |
2699 ASSERT(!isolate->has_pending_exception()); | 2703 ASSERT(!isolate->has_pending_exception()); |
2700 if (!setter->IsUndefined()) { | 2704 if (!setter->IsUndefined()) { |
2701 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 2705 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
2702 return receiver->SetPropertyWithDefinedSetter( | 2706 return receiver->SetPropertyWithDefinedSetter( |
2703 JSReceiver::cast(*setter), *value); | 2707 JSReceiver::cast(*setter), *value); |
2704 } | 2708 } |
2705 | 2709 |
2706 if (strict_mode == kNonStrictMode) return *value; | 2710 if (strict_mode == kNonStrictMode) return *value; |
2707 Handle<Object> args2[] = { name, proxy }; | 2711 Handle<Object> args2[] = { name, proxy }; |
(...skipping 11 matching lines...) Expand all Loading... |
2719 Handle<Object> name(name_raw); | 2723 Handle<Object> name(name_raw); |
2720 | 2724 |
2721 Handle<Object> args[] = { name }; | 2725 Handle<Object> args[] = { name }; |
2722 Handle<Object> result = CallTrap( | 2726 Handle<Object> result = CallTrap( |
2723 "delete", Handle<Object>(), ARRAY_SIZE(args), args); | 2727 "delete", Handle<Object>(), ARRAY_SIZE(args), args); |
2724 if (isolate->has_pending_exception()) return Failure::Exception(); | 2728 if (isolate->has_pending_exception()) return Failure::Exception(); |
2725 | 2729 |
2726 Object* bool_result = result->ToBoolean(); | 2730 Object* bool_result = result->ToBoolean(); |
2727 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { | 2731 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { |
2728 Handle<Object> handler(receiver->handler()); | 2732 Handle<Object> handler(receiver->handler()); |
2729 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); | 2733 Handle<String> trap_name = isolate->factory()->LookupOneByteSymbol( |
| 2734 STATIC_ASCII_VECTOR("delete")); |
2730 Handle<Object> args[] = { handler, trap_name }; | 2735 Handle<Object> args[] = { handler, trap_name }; |
2731 Handle<Object> error = isolate->factory()->NewTypeError( | 2736 Handle<Object> error = isolate->factory()->NewTypeError( |
2732 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); | 2737 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); |
2733 isolate->Throw(*error); | 2738 isolate->Throw(*error); |
2734 return Failure::Exception(); | 2739 return Failure::Exception(); |
2735 } | 2740 } |
2736 return bool_result; | 2741 return bool_result; |
2737 } | 2742 } |
2738 | 2743 |
2739 | 2744 |
(...skipping 25 matching lines...) Expand all Loading... |
2765 if (result->IsUndefined()) return ABSENT; | 2770 if (result->IsUndefined()) return ABSENT; |
2766 | 2771 |
2767 bool has_pending_exception; | 2772 bool has_pending_exception; |
2768 Handle<Object> argv[] = { result }; | 2773 Handle<Object> argv[] = { result }; |
2769 Handle<Object> desc = | 2774 Handle<Object> desc = |
2770 Execution::Call(isolate->to_complete_property_descriptor(), result, | 2775 Execution::Call(isolate->to_complete_property_descriptor(), result, |
2771 ARRAY_SIZE(argv), argv, &has_pending_exception); | 2776 ARRAY_SIZE(argv), argv, &has_pending_exception); |
2772 if (has_pending_exception) return NONE; | 2777 if (has_pending_exception) return NONE; |
2773 | 2778 |
2774 // Convert result to PropertyAttributes. | 2779 // Convert result to PropertyAttributes. |
2775 Handle<String> enum_n = isolate->factory()->LookupAsciiSymbol("enumerable"); | 2780 Handle<String> enum_n = isolate->factory()->LookupOneByteSymbol( |
| 2781 STATIC_ASCII_VECTOR("enumerable")); |
2776 Handle<Object> enumerable(v8::internal::GetProperty(desc, enum_n)); | 2782 Handle<Object> enumerable(v8::internal::GetProperty(desc, enum_n)); |
2777 if (isolate->has_pending_exception()) return NONE; | 2783 if (isolate->has_pending_exception()) return NONE; |
2778 Handle<String> conf_n = isolate->factory()->LookupAsciiSymbol("configurable"); | 2784 Handle<String> conf_n = isolate->factory()->LookupOneByteSymbol( |
| 2785 STATIC_ASCII_VECTOR("configurable")); |
2779 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_n)); | 2786 Handle<Object> configurable(v8::internal::GetProperty(desc, conf_n)); |
2780 if (isolate->has_pending_exception()) return NONE; | 2787 if (isolate->has_pending_exception()) return NONE; |
2781 Handle<String> writ_n = isolate->factory()->LookupAsciiSymbol("writable"); | 2788 Handle<String> writ_n = isolate->factory()->LookupOneByteSymbol( |
| 2789 STATIC_ASCII_VECTOR("writable")); |
2782 Handle<Object> writable(v8::internal::GetProperty(desc, writ_n)); | 2790 Handle<Object> writable(v8::internal::GetProperty(desc, writ_n)); |
2783 if (isolate->has_pending_exception()) return NONE; | 2791 if (isolate->has_pending_exception()) return NONE; |
2784 | 2792 |
2785 if (configurable->IsFalse()) { | 2793 if (configurable->IsFalse()) { |
2786 Handle<String> trap = | 2794 Handle<String> trap = isolate->factory()->LookupOneByteSymbol( |
2787 isolate->factory()->LookupAsciiSymbol("getPropertyDescriptor"); | 2795 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
2788 Handle<Object> args[] = { handler, trap, name }; | 2796 Handle<Object> args[] = { handler, trap, name }; |
2789 Handle<Object> error = isolate->factory()->NewTypeError( | 2797 Handle<Object> error = isolate->factory()->NewTypeError( |
2790 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 2798 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
2791 isolate->Throw(*error); | 2799 isolate->Throw(*error); |
2792 return NONE; | 2800 return NONE; |
2793 } | 2801 } |
2794 | 2802 |
2795 int attributes = NONE; | 2803 int attributes = NONE; |
2796 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; | 2804 if (enumerable->ToBoolean()->IsFalse()) attributes |= DONT_ENUM; |
2797 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; | 2805 if (configurable->ToBoolean()->IsFalse()) attributes |= DONT_DELETE; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 } | 2845 } |
2838 | 2846 |
2839 | 2847 |
2840 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name, | 2848 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name, |
2841 Handle<Object> derived, | 2849 Handle<Object> derived, |
2842 int argc, | 2850 int argc, |
2843 Handle<Object> argv[]) { | 2851 Handle<Object> argv[]) { |
2844 Isolate* isolate = GetIsolate(); | 2852 Isolate* isolate = GetIsolate(); |
2845 Handle<Object> handler(this->handler()); | 2853 Handle<Object> handler(this->handler()); |
2846 | 2854 |
2847 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol(name); | 2855 Handle<String> trap_name = isolate->factory()->LookupUtf8Symbol(name); |
2848 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); | 2856 Handle<Object> trap(v8::internal::GetProperty(handler, trap_name)); |
2849 if (isolate->has_pending_exception()) return trap; | 2857 if (isolate->has_pending_exception()) return trap; |
2850 | 2858 |
2851 if (trap->IsUndefined()) { | 2859 if (trap->IsUndefined()) { |
2852 if (derived.is_null()) { | 2860 if (derived.is_null()) { |
2853 Handle<Object> args[] = { handler, trap_name }; | 2861 Handle<Object> args[] = { handler, trap_name }; |
2854 Handle<Object> error = isolate->factory()->NewTypeError( | 2862 Handle<Object> error = isolate->factory()->NewTypeError( |
2855 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); | 2863 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); |
2856 isolate->Throw(*error); | 2864 isolate->Throw(*error); |
2857 return Handle<Object>(); | 2865 return Handle<Object>(); |
(...skipping 5461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8319 Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) { | 8327 Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) { |
8320 return Context::cast(literals->get(JSFunction::kLiteralNativeContextIndex)); | 8328 return Context::cast(literals->get(JSFunction::kLiteralNativeContextIndex)); |
8321 } | 8329 } |
8322 | 8330 |
8323 | 8331 |
8324 MaybeObject* Oddball::Initialize(const char* to_string, | 8332 MaybeObject* Oddball::Initialize(const char* to_string, |
8325 Object* to_number, | 8333 Object* to_number, |
8326 byte kind) { | 8334 byte kind) { |
8327 String* symbol; | 8335 String* symbol; |
8328 { MaybeObject* maybe_symbol = | 8336 { MaybeObject* maybe_symbol = |
8329 Isolate::Current()->heap()->LookupAsciiSymbol(to_string); | 8337 Isolate::Current()->heap()->LookupUtf8Symbol(CStrVector(to_string)); |
8330 if (!maybe_symbol->To(&symbol)) return maybe_symbol; | 8338 if (!maybe_symbol->To(&symbol)) return maybe_symbol; |
8331 } | 8339 } |
8332 set_to_string(symbol); | 8340 set_to_string(symbol); |
8333 set_to_number(to_number); | 8341 set_to_number(to_number); |
8334 set_kind(kind); | 8342 set_kind(kind); |
8335 return this; | 8343 return this; |
8336 } | 8344 } |
8337 | 8345 |
8338 | 8346 |
8339 String* SharedFunctionInfo::DebugName() { | 8347 String* SharedFunctionInfo::DebugName() { |
(...skipping 4360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12700 return false; | 12708 return false; |
12701 } else { | 12709 } else { |
12702 String* result = String::cast(KeyAt(entry)); | 12710 String* result = String::cast(KeyAt(entry)); |
12703 ASSERT(StringShape(result).IsSymbol()); | 12711 ASSERT(StringShape(result).IsSymbol()); |
12704 *symbol = result; | 12712 *symbol = result; |
12705 return true; | 12713 return true; |
12706 } | 12714 } |
12707 } | 12715 } |
12708 | 12716 |
12709 | 12717 |
12710 MaybeObject* SymbolTable::LookupSymbol(Vector<const char> str, | 12718 MaybeObject* SymbolTable::LookupUtf8Symbol(Vector<const char> str, |
12711 Object** s) { | 12719 Object** s) { |
12712 Utf8SymbolKey key(str, GetHeap()->HashSeed()); | 12720 Utf8SymbolKey key(str, GetHeap()->HashSeed()); |
12713 return LookupKey(&key, s); | 12721 return LookupKey(&key, s); |
12714 } | 12722 } |
12715 | 12723 |
12716 | 12724 |
12717 MaybeObject* SymbolTable::LookupAsciiSymbol(Vector<const char> str, | 12725 MaybeObject* SymbolTable::LookupOneByteSymbol(Vector<const char> str, |
12718 Object** s) { | 12726 Object** s) { |
12719 AsciiSymbolKey key(str, GetHeap()->HashSeed()); | 12727 AsciiSymbolKey key(str, GetHeap()->HashSeed()); |
12720 return LookupKey(&key, s); | 12728 return LookupKey(&key, s); |
12721 } | 12729 } |
12722 | 12730 |
12723 | 12731 |
12724 MaybeObject* SymbolTable::LookupSubStringAsciiSymbol( | 12732 MaybeObject* SymbolTable::LookupSubStringOneByteSymbol( |
12725 Handle<SeqOneByteString> str, | 12733 Handle<SeqOneByteString> str, |
12726 int from, | 12734 int from, |
12727 int length, | 12735 int length, |
12728 Object** s) { | 12736 Object** s) { |
12729 SubStringAsciiSymbolKey key(str, from, length); | 12737 SubStringAsciiSymbolKey key(str, from, length); |
12730 return LookupKey(&key, s); | 12738 return LookupKey(&key, s); |
12731 } | 12739 } |
12732 | 12740 |
12733 | 12741 |
12734 MaybeObject* SymbolTable::LookupTwoByteSymbol(Vector<const uc16> str, | 12742 MaybeObject* SymbolTable::LookupTwoByteSymbol(Vector<const uc16> str, |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14027 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14035 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
14028 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14036 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
14029 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14037 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
14030 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14038 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
14031 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14039 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
14032 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14040 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
14033 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14041 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
14034 } | 14042 } |
14035 | 14043 |
14036 } } // namespace v8::internal | 14044 } } // namespace v8::internal |
OLD | NEW |