| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3120 LOG_API("String::Write"); | 3120 LOG_API("String::Write"); |
| 3121 ENTER_V8; | 3121 ENTER_V8; |
| 3122 ASSERT(start >= 0 && length >= -1); | 3122 ASSERT(start >= 0 && length >= -1); |
| 3123 i::Handle<i::String> str = Utils::OpenHandle(this); | 3123 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 3124 StringTracker::RecordWrite(str); | 3124 StringTracker::RecordWrite(str); |
| 3125 if (hints & HINT_MANY_WRITES_EXPECTED) { | 3125 if (hints & HINT_MANY_WRITES_EXPECTED) { |
| 3126 // Flatten the string for efficiency. This applies whether we are | 3126 // Flatten the string for efficiency. This applies whether we are |
| 3127 // using StringInputBuffer or Get(i) to access the characters. | 3127 // using StringInputBuffer or Get(i) to access the characters. |
| 3128 str->TryFlatten(); | 3128 str->TryFlatten(); |
| 3129 } | 3129 } |
| 3130 int end = length; | 3130 int end = start + length; |
| 3131 if ( (length == -1) || (length > str->length() - start) ) | 3131 if ((length == -1) || (length > str->length() - start) ) |
| 3132 end = str->length() - start; | 3132 end = str->length(); |
| 3133 if (end < 0) return 0; | 3133 if (end < 0) return 0; |
| 3134 i::String::WriteToFlat(*str, buffer, start, end); | 3134 i::String::WriteToFlat(*str, buffer, start, end); |
| 3135 if (length == -1 || end < length) | 3135 if (length == -1 || end - start < length) { |
| 3136 buffer[end] = '\0'; | 3136 buffer[end - start] = '\0'; |
| 3137 return end; | 3137 } |
| 3138 return end - start; |
| 3138 } | 3139 } |
| 3139 | 3140 |
| 3140 | 3141 |
| 3141 bool v8::String::IsExternal() const { | 3142 bool v8::String::IsExternal() const { |
| 3142 EnsureInitialized("v8::String::IsExternal()"); | 3143 EnsureInitialized("v8::String::IsExternal()"); |
| 3143 i::Handle<i::String> str = Utils::OpenHandle(this); | 3144 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 3144 return i::StringShape(*str).IsExternalTwoByte(); | 3145 return i::StringShape(*str).IsExternalTwoByte(); |
| 3145 } | 3146 } |
| 3146 | 3147 |
| 3147 | 3148 |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3794 | 3795 |
| 3795 double v8::Date::NumberValue() const { | 3796 double v8::Date::NumberValue() const { |
| 3796 if (IsDeadCheck("v8::Date::NumberValue()")) return 0; | 3797 if (IsDeadCheck("v8::Date::NumberValue()")) return 0; |
| 3797 LOG_API("Date::NumberValue"); | 3798 LOG_API("Date::NumberValue"); |
| 3798 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3799 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 3799 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 3800 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 3800 return jsvalue->value()->Number(); | 3801 return jsvalue->value()->Number(); |
| 3801 } | 3802 } |
| 3802 | 3803 |
| 3803 | 3804 |
| 3805 void v8::Date::DateTimeConfigurationChangeNotification() { |
| 3806 ON_BAILOUT("v8::Date::DateTimeConfigurationChangeNotification()", return); |
| 3807 LOG_API("Date::DateTimeConfigurationChangeNotification"); |
| 3808 ENTER_V8; |
| 3809 |
| 3810 HandleScope scope; |
| 3811 |
| 3812 // Get the function ResetDateCache (defined in date-delay.js). |
| 3813 i::Handle<i::String> func_name_str = |
| 3814 i::Factory::LookupAsciiSymbol("ResetDateCache"); |
| 3815 i::MaybeObject* result = i::Top::builtins()->GetProperty(*func_name_str); |
| 3816 i::Object* object_func; |
| 3817 if (!result->ToObject(&object_func)) { |
| 3818 return; |
| 3819 } |
| 3820 |
| 3821 if (object_func->IsJSFunction()) { |
| 3822 i::Handle<i::JSFunction> func = |
| 3823 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); |
| 3824 |
| 3825 // Call ResetDateCache(0 but expect no exceptions: |
| 3826 bool caught_exception = false; |
| 3827 i::Handle<i::Object> result = |
| 3828 i::Execution::TryCall(func, i::Top::builtins(), 0, NULL, |
| 3829 &caught_exception); |
| 3830 } |
| 3831 } |
| 3832 |
| 3833 |
| 3804 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 3834 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
| 3805 char flags_buf[3]; | 3835 char flags_buf[3]; |
| 3806 int num_flags = 0; | 3836 int num_flags = 0; |
| 3807 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 3837 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
| 3808 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 3838 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
| 3809 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 3839 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
| 3810 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 3840 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
| 3811 return i::Factory::LookupSymbol( | 3841 return i::Factory::LookupSymbol( |
| 3812 i::Vector<const char>(flags_buf, num_flags)); | 3842 i::Vector<const char>(flags_buf, num_flags)); |
| 3813 } | 3843 } |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4971 | 5001 |
| 4972 v8::Testing::StressType internal::Testing::stress_type_ = | 5002 v8::Testing::StressType internal::Testing::stress_type_ = |
| 4973 v8::Testing::kStressTypeOpt; | 5003 v8::Testing::kStressTypeOpt; |
| 4974 | 5004 |
| 4975 | 5005 |
| 4976 void Testing::SetStressRunType(Testing::StressType type) { | 5006 void Testing::SetStressRunType(Testing::StressType type) { |
| 4977 internal::Testing::set_stress_type(type); | 5007 internal::Testing::set_stress_type(type); |
| 4978 } | 5008 } |
| 4979 | 5009 |
| 4980 int Testing::GetStressRuns() { | 5010 int Testing::GetStressRuns() { |
| 5011 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs; |
| 4981 #ifdef DEBUG | 5012 #ifdef DEBUG |
| 4982 // In debug mode the code runs much slower so stressing will only make two | 5013 // In debug mode the code runs much slower so stressing will only make two |
| 4983 // runs. | 5014 // runs. |
| 4984 return 2; | 5015 return 2; |
| 4985 #else | 5016 #else |
| 4986 return 5; | 5017 return 5; |
| 4987 #endif | 5018 #endif |
| 4988 } | 5019 } |
| 4989 | 5020 |
| 4990 | 5021 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5105 | 5136 |
| 5106 | 5137 |
| 5107 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5138 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5108 HandleScopeImplementer* thread_local = | 5139 HandleScopeImplementer* thread_local = |
| 5109 reinterpret_cast<HandleScopeImplementer*>(storage); | 5140 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5110 thread_local->IterateThis(v); | 5141 thread_local->IterateThis(v); |
| 5111 return storage + ArchiveSpacePerThread(); | 5142 return storage + ArchiveSpacePerThread(); |
| 5112 } | 5143 } |
| 5113 | 5144 |
| 5114 } } // namespace v8::internal | 5145 } } // namespace v8::internal |
| OLD | NEW |