OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4845 isolate->Enter(); | 4845 isolate->Enter(); |
4846 } | 4846 } |
4847 | 4847 |
4848 | 4848 |
4849 void Isolate::Exit() { | 4849 void Isolate::Exit() { |
4850 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 4850 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
4851 isolate->Exit(); | 4851 isolate->Exit(); |
4852 } | 4852 } |
4853 | 4853 |
4854 | 4854 |
4855 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { | 4855 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
| 4856 : str_(NULL), length_(0) { |
4856 i::Isolate* isolate = i::Isolate::Current(); | 4857 i::Isolate* isolate = i::Isolate::Current(); |
4857 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; | 4858 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; |
4858 if (obj.IsEmpty()) { | 4859 if (obj.IsEmpty()) return; |
4859 str_ = NULL; | |
4860 length_ = 0; | |
4861 return; | |
4862 } | |
4863 ENTER_V8(isolate); | 4860 ENTER_V8(isolate); |
4864 i::HandleScope scope(isolate); | 4861 i::HandleScope scope(isolate); |
4865 TryCatch try_catch; | 4862 TryCatch try_catch; |
4866 Handle<String> str = obj->ToString(); | 4863 Handle<String> str = obj->ToString(); |
4867 if (str.IsEmpty()) { | 4864 if (str.IsEmpty()) return; |
4868 str_ = NULL; | 4865 length_ = str->Utf8Length(); |
4869 length_ = 0; | 4866 str_ = i::NewArray<char>(length_ + 1); |
4870 } else { | 4867 str->WriteUtf8(str_); |
4871 length_ = str->Utf8Length(); | |
4872 str_ = i::NewArray<char>(length_ + 1); | |
4873 str->WriteUtf8(str_); | |
4874 } | |
4875 } | 4868 } |
4876 | 4869 |
4877 | 4870 |
4878 String::Utf8Value::~Utf8Value() { | 4871 String::Utf8Value::~Utf8Value() { |
4879 i::DeleteArray(str_); | 4872 i::DeleteArray(str_); |
4880 } | 4873 } |
4881 | 4874 |
4882 | 4875 |
4883 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) { | 4876 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) |
| 4877 : str_(NULL), length_(0) { |
4884 i::Isolate* isolate = i::Isolate::Current(); | 4878 i::Isolate* isolate = i::Isolate::Current(); |
4885 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; | 4879 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; |
4886 if (obj.IsEmpty()) { | 4880 if (obj.IsEmpty()) return; |
4887 str_ = NULL; | |
4888 length_ = 0; | |
4889 return; | |
4890 } | |
4891 ENTER_V8(isolate); | 4881 ENTER_V8(isolate); |
4892 i::HandleScope scope(isolate); | 4882 i::HandleScope scope(isolate); |
4893 TryCatch try_catch; | 4883 TryCatch try_catch; |
4894 Handle<String> str = obj->ToString(); | 4884 Handle<String> str = obj->ToString(); |
4895 if (str.IsEmpty()) { | 4885 if (str.IsEmpty()) return; |
4896 str_ = NULL; | 4886 length_ = str->Length(); |
4897 length_ = 0; | 4887 str_ = i::NewArray<char>(length_ + 1); |
4898 } else { | 4888 str->WriteAscii(str_); |
4899 length_ = str->Length(); | |
4900 str_ = i::NewArray<char>(length_ + 1); | |
4901 str->WriteAscii(str_); | |
4902 } | |
4903 } | 4889 } |
4904 | 4890 |
4905 | 4891 |
4906 String::AsciiValue::~AsciiValue() { | 4892 String::AsciiValue::~AsciiValue() { |
4907 i::DeleteArray(str_); | 4893 i::DeleteArray(str_); |
4908 } | 4894 } |
4909 | 4895 |
4910 | 4896 |
4911 String::Value::Value(v8::Handle<v8::Value> obj) { | 4897 String::Value::Value(v8::Handle<v8::Value> obj) |
| 4898 : str_(NULL), length_(0) { |
4912 i::Isolate* isolate = i::Isolate::Current(); | 4899 i::Isolate* isolate = i::Isolate::Current(); |
4913 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; | 4900 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; |
4914 if (obj.IsEmpty()) { | 4901 if (obj.IsEmpty()) return; |
4915 str_ = NULL; | |
4916 length_ = 0; | |
4917 return; | |
4918 } | |
4919 ENTER_V8(isolate); | 4902 ENTER_V8(isolate); |
4920 i::HandleScope scope(isolate); | 4903 i::HandleScope scope(isolate); |
4921 TryCatch try_catch; | 4904 TryCatch try_catch; |
4922 Handle<String> str = obj->ToString(); | 4905 Handle<String> str = obj->ToString(); |
4923 if (str.IsEmpty()) { | 4906 if (str.IsEmpty()) return; |
4924 str_ = NULL; | 4907 length_ = str->Length(); |
4925 length_ = 0; | 4908 str_ = i::NewArray<uint16_t>(length_ + 1); |
4926 } else { | 4909 str->Write(str_); |
4927 length_ = str->Length(); | |
4928 str_ = i::NewArray<uint16_t>(length_ + 1); | |
4929 str->Write(str_); | |
4930 } | |
4931 } | 4910 } |
4932 | 4911 |
4933 | 4912 |
4934 String::Value::~Value() { | 4913 String::Value::~Value() { |
4935 i::DeleteArray(str_); | 4914 i::DeleteArray(str_); |
4936 } | 4915 } |
4937 | 4916 |
4938 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { | 4917 Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) { |
4939 i::Isolate* isolate = i::Isolate::Current(); | 4918 i::Isolate* isolate = i::Isolate::Current(); |
4940 LOG_API(isolate, "RangeError"); | 4919 LOG_API(isolate, "RangeError"); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5828 | 5807 |
5829 | 5808 |
5830 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5809 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
5831 HandleScopeImplementer* scope_implementer = | 5810 HandleScopeImplementer* scope_implementer = |
5832 reinterpret_cast<HandleScopeImplementer*>(storage); | 5811 reinterpret_cast<HandleScopeImplementer*>(storage); |
5833 scope_implementer->IterateThis(v); | 5812 scope_implementer->IterateThis(v); |
5834 return storage + ArchiveSpacePerThread(); | 5813 return storage + ArchiveSpacePerThread(); |
5835 } | 5814 } |
5836 | 5815 |
5837 } } // namespace v8::internal | 5816 } } // namespace v8::internal |
OLD | NEW |