| 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 4691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4702 } | 4702 } |
| 4703 } | 4703 } |
| 4704 // Recursive slow path can potentially be unreasonable slow. Flatten. | 4704 // Recursive slow path can potentially be unreasonable slow. Flatten. |
| 4705 str = FlattenGetString(str); | 4705 str = FlattenGetString(str); |
| 4706 Utf8WriterVisitor writer(buffer, capacity, false); | 4706 Utf8WriterVisitor writer(buffer, capacity, false); |
| 4707 i::String::VisitFlat(&writer, *str); | 4707 i::String::VisitFlat(&writer, *str); |
| 4708 return writer.CompleteWrite(write_null, nchars_ref); | 4708 return writer.CompleteWrite(write_null, nchars_ref); |
| 4709 } | 4709 } |
| 4710 | 4710 |
| 4711 | 4711 |
| 4712 int String::WriteAscii(char* buffer, | |
| 4713 int start, | |
| 4714 int length, | |
| 4715 int options) const { | |
| 4716 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
| 4717 LOG_API(isolate, "String::WriteAscii"); | |
| 4718 ENTER_V8(isolate); | |
| 4719 ASSERT(start >= 0 && length >= -1); | |
| 4720 i::Handle<i::String> str = Utils::OpenHandle(this); | |
| 4721 isolate->string_tracker()->RecordWrite(str); | |
| 4722 if (options & HINT_MANY_WRITES_EXPECTED) { | |
| 4723 FlattenString(str); // Flatten the string for efficiency. | |
| 4724 } | |
| 4725 | |
| 4726 int end = length; | |
| 4727 if ((length == -1) || (length > str->length() - start)) { | |
| 4728 end = str->length() - start; | |
| 4729 } | |
| 4730 if (end < 0) return 0; | |
| 4731 i::StringCharacterStream write_stream(*str, isolate->write_iterator(), start); | |
| 4732 int i; | |
| 4733 for (i = 0; i < end; i++) { | |
| 4734 char c = static_cast<char>(write_stream.GetNext()); | |
| 4735 if (c == '\0' && !(options & PRESERVE_ASCII_NULL)) c = ' '; | |
| 4736 buffer[i] = c; | |
| 4737 } | |
| 4738 if (!(options & NO_NULL_TERMINATION) && (length == -1 || i < length)) { | |
| 4739 buffer[i] = '\0'; | |
| 4740 } | |
| 4741 return i; | |
| 4742 } | |
| 4743 | |
| 4744 | |
| 4745 template<typename CharType> | 4712 template<typename CharType> |
| 4746 static inline int WriteHelper(const String* string, | 4713 static inline int WriteHelper(const String* string, |
| 4747 CharType* buffer, | 4714 CharType* buffer, |
| 4748 int start, | 4715 int start, |
| 4749 int length, | 4716 int length, |
| 4750 int options) { | 4717 int options) { |
| 4751 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); | 4718 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); |
| 4752 LOG_API(isolate, "String::Write"); | 4719 LOG_API(isolate, "String::Write"); |
| 4753 ENTER_V8(isolate); | 4720 ENTER_V8(isolate); |
| 4754 ASSERT(start >= 0 && length >= -1); | 4721 ASSERT(start >= 0 && length >= -1); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4976 i::RandomNumberGenerator::SetEntropySource(entropy_source); | 4943 i::RandomNumberGenerator::SetEntropySource(entropy_source); |
| 4977 } | 4944 } |
| 4978 | 4945 |
| 4979 | 4946 |
| 4980 void v8::V8::SetReturnAddressLocationResolver( | 4947 void v8::V8::SetReturnAddressLocationResolver( |
| 4981 ReturnAddressLocationResolver return_address_resolver) { | 4948 ReturnAddressLocationResolver return_address_resolver) { |
| 4982 i::V8::SetReturnAddressLocationResolver(return_address_resolver); | 4949 i::V8::SetReturnAddressLocationResolver(return_address_resolver); |
| 4983 } | 4950 } |
| 4984 | 4951 |
| 4985 | 4952 |
| 4986 bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) { | |
| 4987 return SetFunctionEntryHook(Isolate::GetCurrent(), entry_hook); | |
| 4988 } | |
| 4989 | |
| 4990 | |
| 4991 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, | 4953 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, |
| 4992 FunctionEntryHook entry_hook) { | 4954 FunctionEntryHook entry_hook) { |
| 4993 ASSERT(ext_isolate != NULL); | 4955 ASSERT(ext_isolate != NULL); |
| 4994 ASSERT(entry_hook != NULL); | 4956 ASSERT(entry_hook != NULL); |
| 4995 | 4957 |
| 4996 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); | 4958 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); |
| 4997 | 4959 |
| 4998 // The entry hook can only be set before the Isolate is initialized, as | 4960 // The entry hook can only be set before the Isolate is initialized, as |
| 4999 // otherwise the Isolate's code stubs generated at initialization won't | 4961 // otherwise the Isolate's code stubs generated at initialization won't |
| 5000 // contain entry hooks. | 4962 // contain entry hooks. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5041 } | 5003 } |
| 5042 | 5004 |
| 5043 | 5005 |
| 5044 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 5006 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
| 5045 total_heap_size_executable_(0), | 5007 total_heap_size_executable_(0), |
| 5046 total_physical_size_(0), | 5008 total_physical_size_(0), |
| 5047 used_heap_size_(0), | 5009 used_heap_size_(0), |
| 5048 heap_size_limit_(0) { } | 5010 heap_size_limit_(0) { } |
| 5049 | 5011 |
| 5050 | 5012 |
| 5051 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { | |
| 5052 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | |
| 5053 if (isolate == NULL || !isolate->IsInitialized()) { | |
| 5054 // Isolate is unitialized thus heap is not configured yet. | |
| 5055 heap_statistics->total_heap_size_ = 0; | |
| 5056 heap_statistics->total_heap_size_executable_ = 0; | |
| 5057 heap_statistics->total_physical_size_ = 0; | |
| 5058 heap_statistics->used_heap_size_ = 0; | |
| 5059 heap_statistics->heap_size_limit_ = 0; | |
| 5060 return; | |
| 5061 } | |
| 5062 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); | |
| 5063 return ext_isolate->GetHeapStatistics(heap_statistics); | |
| 5064 } | |
| 5065 | |
| 5066 | |
| 5067 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { | 5013 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { |
| 5068 i::Isolate* isolate = i::Isolate::Current(); | 5014 i::Isolate* isolate = i::Isolate::Current(); |
| 5069 isolate->heap()->VisitExternalResources(visitor); | 5015 isolate->heap()->VisitExternalResources(visitor); |
| 5070 } | 5016 } |
| 5071 | 5017 |
| 5072 | 5018 |
| 5073 class VisitorAdapter : public i::ObjectVisitor { | 5019 class VisitorAdapter : public i::ObjectVisitor { |
| 5074 public: | 5020 public: |
| 5075 explicit VisitorAdapter(PersistentHandleVisitor* visitor) | 5021 explicit VisitorAdapter(PersistentHandleVisitor* visitor) |
| 5076 : visitor_(visitor) {} | 5022 : visitor_(visitor) {} |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6969 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | 6915 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
| 6970 } | 6916 } |
| 6971 | 6917 |
| 6972 | 6918 |
| 6973 const char* CpuProfileNode::GetBailoutReason() const { | 6919 const char* CpuProfileNode::GetBailoutReason() const { |
| 6974 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6920 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 6975 return node->entry()->bailout_reason(); | 6921 return node->entry()->bailout_reason(); |
| 6976 } | 6922 } |
| 6977 | 6923 |
| 6978 | 6924 |
| 6979 double CpuProfileNode::GetSelfSamplesCount() const { | |
| 6980 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | |
| 6981 } | |
| 6982 | |
| 6983 | |
| 6984 unsigned CpuProfileNode::GetHitCount() const { | 6925 unsigned CpuProfileNode::GetHitCount() const { |
| 6985 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | 6926 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
| 6986 } | 6927 } |
| 6987 | 6928 |
| 6988 | 6929 |
| 6989 unsigned CpuProfileNode::GetCallUid() const { | 6930 unsigned CpuProfileNode::GetCallUid() const { |
| 6990 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); | 6931 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); |
| 6991 } | 6932 } |
| 6992 | 6933 |
| 6993 | 6934 |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7575 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7516 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7576 Address callback_address = | 7517 Address callback_address = |
| 7577 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7518 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7578 VMState<EXTERNAL> state(isolate); | 7519 VMState<EXTERNAL> state(isolate); |
| 7579 ExternalCallbackScope call_scope(isolate, callback_address); | 7520 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7580 callback(info); | 7521 callback(info); |
| 7581 } | 7522 } |
| 7582 | 7523 |
| 7583 | 7524 |
| 7584 } } // namespace v8::internal | 7525 } } // namespace v8::internal |
| OLD | NEW |