From b1d4bf41582db8481c6c96ae5db86d27062ff5a9 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 20 Oct 2014 12:07:45 +0000 Subject: [PATCH] Move some Runtime:: functions and remove runtime.h as include when unnecessary. R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/662413002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24736 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 67 +++++++++++++++++++++++++++++---- src/runtime/runtime-array.cc | 1 - src/runtime/runtime-collections.cc | 1 - src/runtime/runtime-compiler.cc | 1 - src/runtime/runtime-date.cc | 1 - src/runtime/runtime-debug.cc | 4 +- src/runtime/runtime-function.cc | 1 - src/runtime/runtime-generator.cc | 1 - src/runtime/runtime-i18n.cc | 1 - src/runtime/runtime-internal.cc | 1 - src/runtime/runtime-json.cc | 1 - src/runtime/runtime-liveedit.cc | 2 +- src/runtime/runtime-maths.cc | 1 - src/runtime/runtime-numbers.cc | 1 - src/runtime/runtime-object.cc | 57 ---------------------------- src/runtime/runtime-observe.cc | 1 - src/runtime/runtime-proxy.cc | 1 - src/runtime/runtime-regexp.cc | 42 --------------------- src/runtime/runtime-scopes.cc | 1 - src/runtime/runtime-strings.cc | 46 ++++++++++++++++++++-- src/runtime/runtime-symbol.cc | 1 - src/runtime/runtime-test.cc | 3 +- src/runtime/runtime-uri.cc | 1 - src/runtime/runtime-utils.h | 9 ++--- src/runtime/runtime.h | 22 ++++------- src/runtime/string-builder.h | 6 +-- test/cctest/test-func-name-inference.cc | 18 +++++---- 27 files changed, 130 insertions(+), 162 deletions(-) diff --git a/src/api.cc b/src/api.cc index 0c78b5f..ae6ab1a 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3173,6 +3173,44 @@ bool v8::Object::SetPrivate(v8::Handle key, v8::Handle value) { } +i::MaybeHandle DeleteObjectProperty( + i::Isolate* isolate, i::Handle receiver, + i::Handle key, i::JSReceiver::DeleteMode mode) { + // Check if the given key is an array index. + uint32_t index; + if (key->ToArrayIndex(&index)) { + // In Firefox/SpiderMonkey, Safari and Opera you can access the + // characters of a string using [] notation. In the case of a + // String object we just need to redirect the deletion to the + // underlying string if the index is in range. Since the + // underlying string does nothing with the deletion, we can ignore + // such deletions. + if (receiver->IsStringObjectWithCharacterAt(index)) { + return isolate->factory()->true_value(); + } + + return i::JSReceiver::DeleteElement(receiver, index, mode); + } + + i::Handle name; + if (key->IsName()) { + name = i::Handle::cast(key); + } else { + // Call-back into JavaScript to convert the key to a string. + i::Handle converted; + if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) { + return i::MaybeHandle(); + } + name = i::Handle::cast(converted); + } + + if (name->IsString()) { + name = i::String::Flatten(i::Handle::cast(name)); + } + return i::JSReceiver::DeleteProperty(receiver, name, mode); +} + + bool v8::Object::ForceDelete(v8::Handle key) { i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); @@ -3191,8 +3229,9 @@ bool v8::Object::ForceDelete(v8::Handle key) { EXCEPTION_PREAMBLE(isolate); i::Handle obj; - has_pending_exception = !i::Runtime::DeleteObjectProperty( - isolate, self, key_obj, i::JSReceiver::FORCE_DELETION).ToHandle(&obj); + has_pending_exception = + !DeleteObjectProperty(isolate, self, key_obj, + i::JSReceiver::FORCE_DELETION).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(isolate, false); return obj->IsTrue(); } @@ -3445,8 +3484,9 @@ bool v8::Object::Delete(v8::Handle key) { i::Handle key_obj = Utils::OpenHandle(*key); EXCEPTION_PREAMBLE(isolate); i::Handle obj; - has_pending_exception = !i::Runtime::DeleteObjectProperty( - isolate, self, key_obj, i::JSReceiver::NORMAL_DELETION).ToHandle(&obj); + has_pending_exception = + !DeleteObjectProperty(isolate, self, key_obj, + i::JSReceiver::NORMAL_DELETION).ToHandle(&obj); EXCEPTION_BAILOUT_CHECK(isolate, false); return obj->IsTrue(); } @@ -3464,11 +3504,22 @@ bool v8::Object::Has(v8::Handle key) { i::Handle self = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); EXCEPTION_PREAMBLE(isolate); - i::Handle obj; - has_pending_exception = !i::Runtime::HasObjectProperty( - isolate, self, key_obj).ToHandle(&obj); + Maybe maybe; + // Check if the given key is an array index. + uint32_t index; + if (key_obj->ToArrayIndex(&index)) { + maybe = i::JSReceiver::HasElement(self, index); + } else { + // Convert the key to a name - possibly by calling back into JavaScript. + i::Handle name; + if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { + maybe = i::JSReceiver::HasProperty(self, name); + } + } + if (!maybe.has_value) has_pending_exception = true; EXCEPTION_BAILOUT_CHECK(isolate, false); - return obj->IsTrue(); + DCHECK(maybe.has_value); + return maybe.value; } diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc index 939898e..5a6bba4 100644 --- a/src/runtime/runtime-array.cc +++ b/src/runtime/runtime-array.cc @@ -5,7 +5,6 @@ #include "src/v8.h" #include "src/arguments.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc index d0d6aa6..c4f7418 100644 --- a/src/runtime/runtime-collections.cc +++ b/src/runtime/runtime-collections.cc @@ -5,7 +5,6 @@ #include "src/v8.h" #include "src/arguments.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc index 4d258f9..94cd343 100644 --- a/src/runtime/runtime-compiler.cc +++ b/src/runtime/runtime-compiler.cc @@ -10,7 +10,6 @@ #include "src/frames.h" #include "src/full-codegen.h" #include "src/isolate-inl.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/v8threads.h" #include "src/vm-state-inl.h" diff --git a/src/runtime/runtime-date.cc b/src/runtime/runtime-date.cc index 7d20eed..65d8fc6 100644 --- a/src/runtime/runtime-date.cc +++ b/src/runtime/runtime-date.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/date.h" #include "src/dateparser-inl.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc index af0e574..969ddaf 100644 --- a/src/runtime/runtime-debug.cc +++ b/src/runtime/runtime-debug.cc @@ -385,7 +385,7 @@ static SaveContext* FindSavedContextForFrame(Isolate* isolate, // Advances the iterator to the frame that matches the index and returns the // inlined frame index, or -1 if not found. Skips native JS functions. -int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index) { +int Runtime::FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index) { int count = -1; for (; !it->done(); it->Advance()) { List frames(FLAG_max_inlining_levels + 1); @@ -435,7 +435,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) { JavaScriptFrameIterator it(isolate, id); // Inlined frame index in optimized frame, starting from outer function. - int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index); + int inlined_jsframe_index = Runtime::FindIndexedNonNativeFrame(&it, index); if (inlined_jsframe_index == -1) return heap->undefined_value(); FrameInspector frame_inspector(it.frame(), inlined_jsframe_index, isolate); diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc index a720f81..b57064f 100644 --- a/src/runtime/runtime-function.cc +++ b/src/runtime/runtime-function.cc @@ -9,7 +9,6 @@ #include "src/compiler.h" #include "src/deoptimizer.h" #include "src/frames.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-generator.cc b/src/runtime/runtime-generator.cc index 8463328..9c2add7 100644 --- a/src/runtime/runtime-generator.cc +++ b/src/runtime/runtime-generator.cc @@ -6,7 +6,6 @@ #include "src/arguments.h" #include "src/frames-inl.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc index 4798007..94d9f42 100644 --- a/src/runtime/runtime-i18n.cc +++ b/src/runtime/runtime-i18n.cc @@ -8,7 +8,6 @@ #include "src/arguments.h" #include "src/i18n.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "unicode/brkiter.h" diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc index 8a5ad2e..79dface 100644 --- a/src/runtime/runtime-internal.cc +++ b/src/runtime/runtime-internal.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/bootstrapper.h" #include "src/debug.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-json.cc b/src/runtime/runtime-json.cc index 7a89c51..647f48b 100644 --- a/src/runtime/runtime-json.cc +++ b/src/runtime/runtime-json.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/json-parser.h" #include "src/json-stringifier.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-liveedit.cc b/src/runtime/runtime-liveedit.cc index a121d8f..b453d15 100644 --- a/src/runtime/runtime-liveedit.cc +++ b/src/runtime/runtime-liveedit.cc @@ -279,7 +279,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { } JavaScriptFrameIterator it(isolate, id); - int inlined_jsframe_index = FindIndexedNonNativeFrame(&it, index); + int inlined_jsframe_index = Runtime::FindIndexedNonNativeFrame(&it, index); if (inlined_jsframe_index == -1) return heap->undefined_value(); // We don't really care what the inlined frame index is, since we are // throwing away the entire frame anyways. diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc index 6855675..6397ad1 100644 --- a/src/runtime/runtime-maths.cc +++ b/src/runtime/runtime-maths.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/assembler.h" #include "src/codegen.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/third_party/fdlibm/fdlibm.h" diff --git a/src/runtime/runtime-numbers.cc b/src/runtime/runtime-numbers.cc index 17c52e1..7953dac 100644 --- a/src/runtime/runtime-numbers.cc +++ b/src/runtime/runtime-numbers.cc @@ -8,7 +8,6 @@ #include "src/bootstrapper.h" #include "src/codegen.h" #include "src/misc-intrinsics.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index b3e0b25..74cb8cb 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -65,27 +65,6 @@ MaybeHandle Runtime::ToName(Isolate* isolate, Handle key) { } -MaybeHandle Runtime::HasObjectProperty(Isolate* isolate, - Handle object, - Handle key) { - Maybe maybe; - // Check if the given key is an array index. - uint32_t index; - if (key->ToArrayIndex(&index)) { - maybe = JSReceiver::HasElement(object, index); - } else { - // Convert the key to a name - possibly by calling back into JavaScript. - Handle name; - ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object); - - maybe = JSReceiver::HasProperty(object, name); - } - - if (!maybe.has_value) return MaybeHandle(); - return isolate->factory()->ToBoolean(maybe.value); -} - - MaybeHandle Runtime::GetObjectProperty(Isolate* isolate, Handle object, Handle key) { @@ -263,42 +242,6 @@ MaybeHandle Runtime::DefineObjectProperty(Handle js_object, } -MaybeHandle Runtime::DeleteObjectProperty(Isolate* isolate, - Handle receiver, - Handle key, - JSReceiver::DeleteMode mode) { - // Check if the given key is an array index. - uint32_t index; - if (key->ToArrayIndex(&index)) { - // In Firefox/SpiderMonkey, Safari and Opera you can access the - // characters of a string using [] notation. In the case of a - // String object we just need to redirect the deletion to the - // underlying string if the index is in range. Since the - // underlying string does nothing with the deletion, we can ignore - // such deletions. - if (receiver->IsStringObjectWithCharacterAt(index)) { - return isolate->factory()->true_value(); - } - - return JSReceiver::DeleteElement(receiver, index, mode); - } - - Handle name; - if (key->IsName()) { - name = Handle::cast(key); - } else { - // Call-back into JavaScript to convert the key to a string. - Handle converted; - ASSIGN_RETURN_ON_EXCEPTION(isolate, converted, - Execution::ToString(isolate, key), Object); - name = Handle::cast(converted); - } - - if (name->IsString()) name = String::Flatten(Handle::cast(name)); - return JSReceiver::DeleteProperty(receiver, name, mode); -} - - RUNTIME_FUNCTION(Runtime_GetPrototype) { HandleScope scope(isolate); DCHECK(args.length() == 1); diff --git a/src/runtime/runtime-observe.cc b/src/runtime/runtime-observe.cc index eefdba8..ab7f250 100644 --- a/src/runtime/runtime-observe.cc +++ b/src/runtime/runtime-observe.cc @@ -5,7 +5,6 @@ #include "src/v8.h" #include "src/arguments.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-proxy.cc b/src/runtime/runtime-proxy.cc index a05ca05..baf7cdb 100644 --- a/src/runtime/runtime-proxy.cc +++ b/src/runtime/runtime-proxy.cc @@ -5,7 +5,6 @@ #include "src/v8.h" #include "src/arguments.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc index 840264f..b613f8a 100644 --- a/src/runtime/runtime-regexp.cc +++ b/src/runtime/runtime-regexp.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/jsregexp-inl.h" #include "src/jsregexp.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/runtime/string-builder.h" #include "src/string-search.h" @@ -1094,46 +1093,5 @@ RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { CONVERT_ARG_CHECKED(Object, obj, 0); return isolate->heap()->ToBoolean(obj->IsJSRegExp()); } - - -// Perform string match of pattern on subject, starting at start index. -// Caller must ensure that 0 <= start_index <= sub->length(), -// and should check that pat->length() + start_index <= sub->length(). -int Runtime::StringMatch(Isolate* isolate, Handle sub, - Handle pat, int start_index) { - DCHECK(0 <= start_index); - DCHECK(start_index <= sub->length()); - - int pattern_length = pat->length(); - if (pattern_length == 0) return start_index; - - int subject_length = sub->length(); - if (start_index + pattern_length > subject_length) return -1; - - sub = String::Flatten(sub); - pat = String::Flatten(pat); - - DisallowHeapAllocation no_gc; // ensure vectors stay valid - // Extract flattened substrings of cons strings before getting encoding. - String::FlatContent seq_sub = sub->GetFlatContent(); - String::FlatContent seq_pat = pat->GetFlatContent(); - - // dispatch on type of strings - if (seq_pat.IsOneByte()) { - Vector pat_vector = seq_pat.ToOneByteVector(); - if (seq_sub.IsOneByte()) { - return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector, - start_index); - } - return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, - start_index); - } - Vector pat_vector = seq_pat.ToUC16Vector(); - if (seq_sub.IsOneByte()) { - return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector, - start_index); - } - return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, start_index); -} } } // namespace v8::internal diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc index 4545369..c935cda 100644 --- a/src/runtime/runtime-scopes.cc +++ b/src/runtime/runtime-scopes.cc @@ -7,7 +7,6 @@ #include "src/accessors.h" #include "src/arguments.h" #include "src/frames-inl.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/scopeinfo.h" #include "src/scopes.h" diff --git a/src/runtime/runtime-strings.cc b/src/runtime/runtime-strings.cc index 1418a5f..ff683dc 100644 --- a/src/runtime/runtime-strings.cc +++ b/src/runtime/runtime-strings.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/jsregexp-inl.h" #include "src/jsregexp.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/runtime/string-builder.h" #include "src/string-search.h" @@ -16,6 +15,47 @@ namespace v8 { namespace internal { +// Perform string match of pattern on subject, starting at start index. +// Caller must ensure that 0 <= start_index <= sub->length(), +// and should check that pat->length() + start_index <= sub->length(). +int StringMatch(Isolate* isolate, Handle sub, Handle pat, + int start_index) { + DCHECK(0 <= start_index); + DCHECK(start_index <= sub->length()); + + int pattern_length = pat->length(); + if (pattern_length == 0) return start_index; + + int subject_length = sub->length(); + if (start_index + pattern_length > subject_length) return -1; + + sub = String::Flatten(sub); + pat = String::Flatten(pat); + + DisallowHeapAllocation no_gc; // ensure vectors stay valid + // Extract flattened substrings of cons strings before getting encoding. + String::FlatContent seq_sub = sub->GetFlatContent(); + String::FlatContent seq_pat = pat->GetFlatContent(); + + // dispatch on type of strings + if (seq_pat.IsOneByte()) { + Vector pat_vector = seq_pat.ToOneByteVector(); + if (seq_sub.IsOneByte()) { + return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector, + start_index); + } + return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, + start_index); + } + Vector pat_vector = seq_pat.ToUC16Vector(); + if (seq_sub.IsOneByte()) { + return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector, + start_index); + } + return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, start_index); +} + + // This may return an empty MaybeHandle if an exception is thrown or // we abort due to reaching the recursion limit. MaybeHandle StringReplaceOneCharWithString( @@ -47,7 +87,7 @@ MaybeHandle StringReplaceOneCharWithString( return subject; } else { - int index = Runtime::StringMatch(isolate, subject, search, 0); + int index = StringMatch(isolate, subject, search, 0); if (index == -1) return subject; *found = true; Handle first = isolate->factory()->NewSubString(subject, 0, index); @@ -101,7 +141,7 @@ RUNTIME_FUNCTION(Runtime_StringIndexOf) { if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); RUNTIME_ASSERT(start_index <= static_cast(sub->length())); - int position = Runtime::StringMatch(isolate, sub, pat, start_index); + int position = StringMatch(isolate, sub, pat, start_index); return Smi::FromInt(position); } diff --git a/src/runtime/runtime-symbol.cc b/src/runtime/runtime-symbol.cc index 4d333ac..31b6bed 100644 --- a/src/runtime/runtime-symbol.cc +++ b/src/runtime/runtime-symbol.cc @@ -5,7 +5,6 @@ #include "src/v8.h" #include "src/arguments.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 095d97f..da39b38 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -7,7 +7,6 @@ #include "src/arguments.h" #include "src/deoptimizer.h" #include "src/full-codegen.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" namespace v8 { @@ -391,7 +390,7 @@ RUNTIME_FUNCTION(Runtime_ListNatives) { #undef ADD_ENTRY DCHECK_EQ(index, entry_count); Handle result = factory->NewJSArrayWithElements(elements); - return *result; + return (*result); } #endif diff --git a/src/runtime/runtime-uri.cc b/src/runtime/runtime-uri.cc index 10e21be..16e80b5 100644 --- a/src/runtime/runtime-uri.cc +++ b/src/runtime/runtime-uri.cc @@ -6,7 +6,6 @@ #include "src/arguments.h" #include "src/conversions.h" -#include "src/runtime/runtime.h" #include "src/runtime/runtime-utils.h" #include "src/string-search.h" #include "src/utils.h" diff --git a/src/runtime/runtime-utils.h b/src/runtime/runtime-utils.h index 968ee8a..95d75f5 100644 --- a/src/runtime/runtime-utils.h +++ b/src/runtime/runtime-utils.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_RUNTIME_UTILS_H_ -#define V8_RUNTIME_UTILS_H_ +#ifndef V8_RUNTIME_RUNTIME_UTILS_H_ +#define V8_RUNTIME_RUNTIME_UTILS_H_ namespace v8 { @@ -141,10 +141,7 @@ static inline ObjectPair MakePair(Object* x, Object* y) { } #endif -class JavaScriptFrameIterator; - -int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index); } } // namespace v8::internal -#endif // V8_RUNTIME_UTILS_H_ +#endif // V8_RUNTIME_RUNTIME_UTILS_H_ diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index a3b1441..084e35d 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_RUNTIME_H_ -#define V8_RUNTIME_H_ +#ifndef V8_RUNTIME_RUNTIME_H_ +#define V8_RUNTIME_RUNTIME_H_ #include "src/allocation.h" #include "src/objects.h" @@ -777,6 +777,9 @@ class RuntimeState { }; +class JavaScriptFrameIterator; // Forward declaration. + + class Runtime : public AllStatic { public: enum FunctionId { @@ -828,10 +831,6 @@ class Runtime : public AllStatic { // Get the intrinsic function with the given function entry address. static const Function* FunctionForEntry(Address ref); - // General-purpose helper functions for runtime system. - static int StringMatch(Isolate* isolate, Handle sub, - Handle pat, int index); - // TODO(1240886): Some of the following methods are *not* handle safe, but // accept handle arguments. This seems fragile. @@ -848,13 +847,6 @@ class Runtime : public AllStatic { Handle object, Handle key, Handle value, PropertyAttributes attr); - MUST_USE_RESULT static MaybeHandle DeleteObjectProperty( - Isolate* isolate, Handle object, Handle key, - JSReceiver::DeleteMode mode); - - MUST_USE_RESULT static MaybeHandle HasObjectProperty( - Isolate* isolate, Handle object, Handle key); - MUST_USE_RESULT static MaybeHandle GetObjectProperty( Isolate* isolate, Handle object, Handle key); @@ -876,6 +868,8 @@ class Runtime : public AllStatic { static void FreeArrayBuffer(Isolate* isolate, JSArrayBuffer* phantom_array_buffer); + static int FindIndexedNonNativeFrame(JavaScriptFrameIterator* it, int index); + enum TypedArrayId { // arrayIds below should be synchromized with typedarray.js natives. ARRAY_ID_UINT8 = 1, @@ -918,4 +912,4 @@ class DeclareGlobalsStrictMode : public BitField {}; } // namespace internal } // namespace v8 -#endif // V8_RUNTIME_H_ +#endif // V8_RUNTIME_RUNTIME_H_ diff --git a/src/runtime/string-builder.h b/src/runtime/string-builder.h index 37ff7b7..890b7f6 100644 --- a/src/runtime/string-builder.h +++ b/src/runtime/string-builder.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_STRING_BUILDER_H_ -#define V8_STRING_BUILDER_H_ +#ifndef V8_RUNTIME_STRING_BUILDER_H_ +#define V8_RUNTIME_STRING_BUILDER_H_ namespace v8 { namespace internal { @@ -293,4 +293,4 @@ class ReplacementStringBuilder { } } // namespace v8::internal -#endif // V8_STRING_BUILDER_H_ +#endif // V8_RUNTIME_STRING_BUILDER_H_ diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc index ceceff6..7f3dafc 100644 --- a/test/cctest/test-func-name-inference.cc +++ b/test/cctest/test-func-name-inference.cc @@ -30,7 +30,7 @@ #include "src/api.h" #include "src/debug.h" -#include "src/runtime/runtime.h" +#include "src/string-search.h" #include "test/cctest/cctest.h" @@ -46,13 +46,13 @@ using ::v8::internal::Script; using ::v8::internal::SmartArrayPointer; using ::v8::internal::SharedFunctionInfo; using ::v8::internal::String; +using ::v8::internal::Vector; static void CheckFunctionName(v8::Handle script, const char* func_pos_src, const char* ref_inferred_name) { Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); // Get script source. Handle obj = v8::Utils::OpenHandle(*script); @@ -69,12 +69,14 @@ static void CheckFunctionName(v8::Handle script, Handle script_src(String::cast(i_script->source())); // Find the position of a given func source substring in the source. - Handle func_pos_str = - factory->NewStringFromAsciiChecked(func_pos_src); - int func_pos = Runtime::StringMatch(isolate, - script_src, - func_pos_str, - 0); + int func_pos; + { + i::DisallowHeapAllocation no_gc; + Vector func_pos_str = i::OneByteVector(func_pos_src); + String::FlatContent script_content = script_src->GetFlatContent(); + func_pos = SearchString(isolate, script_content.ToOneByteVector(), + func_pos_str, 0); + } CHECK_NE(0, func_pos); // Obtain SharedFunctionInfo for the function. -- 2.7.4