Commit 77ddcfb3 authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Remove unused code

This CL removes code that is now unused since the port of regexp.js has been
completed. Removed functions / classes are:

* regexp.js (GetSubstitution moved to string.js)
* RegExpConstructResult stub
* RegExpFlags intrinsic
* RegExpSource intrinsic
* RegExpInitializeAndCompile runtime function

BUG=v8:5339

Review-Url: https://codereview.chromium.org/2448463002
Cr-Commit-Position: refs/heads/master@{#40547}
parent d7a18896
......@@ -410,7 +410,6 @@ action("js2c") {
"src/js/symbol.js",
"src/js/array.js",
"src/js/string.js",
"src/js/regexp.js",
"src/js/arraybuffer.js",
"src/js/typedarray.js",
"src/js/collection.js",
......
......@@ -207,13 +207,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2, r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0, r1};
......
......@@ -226,16 +226,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x2: length
// x1: index (of last match)
// x0: string
Register registers[] = {x2, x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x0: value (js_array)
......
......@@ -197,12 +197,6 @@ Callable CodeFactory::NumberToString(Isolate* isolate) {
return make_callable(stub);
}
// static
Callable CodeFactory::RegExpConstructResult(Isolate* isolate) {
RegExpConstructResultStub stub(isolate);
return make_callable(stub);
}
// static
Callable CodeFactory::RegExpExec(Isolate* isolate) {
RegExpExecStub stub(isolate);
......
......@@ -83,7 +83,6 @@ class V8_EXPORT_PRIVATE CodeFactory final {
OrdinaryToPrimitiveHint hint);
static Callable NumberToString(Isolate* isolate);
static Callable RegExpConstructResult(Isolate* isolate);
static Callable RegExpExec(Isolate* isolate);
static Callable Add(Isolate* isolate);
......
......@@ -1153,28 +1153,5 @@ Handle<Code> LoadDictionaryElementStub::GenerateCode() {
return DoGenerateCode(this);
}
template<>
HValue* CodeStubGraphBuilder<RegExpConstructResultStub>::BuildCodeStub() {
// Determine the parameters.
HValue* length = GetParameter(Descriptor::kLength);
HValue* index = GetParameter(Descriptor::kIndex);
HValue* input = GetParameter(Descriptor::kInput);
// TODO(turbofan): This codestub has regressed to need a frame on ia32 at some
// point and wasn't caught since it wasn't built in the snapshot. We should
// probably just replace with a TurboFan stub rather than fixing it.
#if !(V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87)
info()->MarkMustNotHaveEagerFrame();
#endif
return BuildRegExpConstructResult(length, index, input);
}
Handle<Code> RegExpConstructResultStub::GenerateCode() {
return DoGenerateCode(this);
}
} // namespace internal
} // namespace v8
......@@ -2413,15 +2413,6 @@ CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const {
}
}
void RegExpConstructResultStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize(
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
descriptor->SetMissHandler(Runtime::kRegExpConstructResult);
}
void TransitionElementsKindStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
descriptor->Initialize(
......
......@@ -78,7 +78,6 @@ class ObjectLiteral;
V(BinaryOpIC) \
V(BinaryOpWithAllocationSite) \
V(ToBooleanIC) \
V(RegExpConstructResult) \
V(TransitionElementsKind) \
/* --- TurboFanCodeStubs --- */ \
V(AllocateHeapNumber) \
......@@ -1799,17 +1798,6 @@ class RegExpExecStub: public PlatformCodeStub {
DEFINE_PLATFORM_CODE_STUB(RegExpExec, PlatformCodeStub);
};
// TODO(jgruber): Remove this once all uses in regexp.js have been removed.
class RegExpConstructResultStub final : public HydrogenCodeStub {
public:
explicit RegExpConstructResultStub(Isolate* isolate)
: HydrogenCodeStub(isolate) { }
DEFINE_CALL_INTERFACE_DESCRIPTOR(RegExpConstructResult);
DEFINE_HYDROGEN_CODE_STUB(RegExpConstructResult, HydrogenCodeStub);
};
// TODO(bmeurer/mvstanton): Turn CallConstructStub into ConstructICStub.
class CallConstructStub final : public PlatformCodeStub {
public:
......
......@@ -54,14 +54,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceFixedArrayGet(node);
case Runtime::kInlineFixedArraySet:
return ReduceFixedArraySet(node);
case Runtime::kInlineRegExpConstructResult:
return ReduceRegExpConstructResult(node);
case Runtime::kInlineRegExpExec:
return ReduceRegExpExec(node);
case Runtime::kInlineRegExpFlags:
return ReduceRegExpFlags(node);
case Runtime::kInlineRegExpSource:
return ReduceRegExpSource(node);
case Runtime::kInlineSubString:
return ReduceSubString(node);
case Runtime::kInlineToInteger:
......@@ -234,37 +228,11 @@ Reduction JSIntrinsicLowering::ReduceFixedArraySet(Node* node) {
}
Reduction JSIntrinsicLowering::ReduceRegExpConstructResult(Node* node) {
// TODO(bmeurer): Introduce JSCreateRegExpResult?
return Change(node, CodeFactory::RegExpConstructResult(isolate()), 0);
}
Reduction JSIntrinsicLowering::ReduceRegExpExec(Node* node) {
return Change(node, CodeFactory::RegExpExec(isolate()), 4);
}
Reduction JSIntrinsicLowering::ReduceRegExpFlags(Node* node) {
Node* const receiver = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Operator const* const op =
simplified()->LoadField(AccessBuilder::ForJSRegExpFlags());
return Change(node, op, receiver, effect, control);
}
Reduction JSIntrinsicLowering::ReduceRegExpSource(Node* node) {
Node* const receiver = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Operator const* const op =
simplified()->LoadField(AccessBuilder::ForJSRegExpSource());
return Change(node, op, receiver, effect, control);
}
Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
return Change(node, CodeFactory::SubString(isolate()), 3);
}
......
......@@ -49,10 +49,7 @@ class V8_EXPORT_PRIVATE JSIntrinsicLowering final
Reduction ReduceIsSmi(Node* node);
Reduction ReduceFixedArrayGet(Node* node);
Reduction ReduceFixedArraySet(Node* node);
Reduction ReduceRegExpConstructResult(Node* node);
Reduction ReduceRegExpExec(Node* node);
Reduction ReduceRegExpFlags(Node* node);
Reduction ReduceRegExpSource(Node* node);
Reduction ReduceSubString(Node* node);
Reduction ReduceToInteger(Node* node);
Reduction ReduceToLength(Node* node);
......
......@@ -168,8 +168,6 @@ bool Linkage::NeedsFrameStateInput(Runtime::FunctionId function) {
case Runtime::kInlineIsRegExp:
case Runtime::kInlineIsSmi:
case Runtime::kInlineIsTypedArray:
case Runtime::kInlineRegExpFlags:
case Runtime::kInlineRegExpSource:
return false;
default:
......
......@@ -1402,7 +1402,6 @@ Type* Typer::Visitor::TypeJSCallRuntime(Node* node) {
case Runtime::kInlineIsRegExp:
return Type::Boolean();
case Runtime::kInlineCreateIterResultObject:
case Runtime::kInlineRegExpConstructResult:
return Type::OtherObject();
case Runtime::kInlineSubString:
case Runtime::kInlineStringCharFromCode:
......
......@@ -1844,67 +1844,6 @@ HValue* HGraphBuilder::BuildCreateIterResultObject(HValue* value,
}
HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length,
HValue* index,
HValue* input) {
NoObservableSideEffectsScope scope(this);
HConstant* max_length = Add<HConstant>(JSArray::kInitialMaxFastElementArray);
Add<HBoundsCheck>(length, max_length);
// Generate size calculation code here in order to make it dominate
// the JSRegExpResult allocation.
ElementsKind elements_kind = FAST_ELEMENTS;
HValue* size = BuildCalculateElementsSize(elements_kind, length);
// Allocate the JSRegExpResult and the FixedArray in one step.
HValue* result =
Add<HAllocate>(Add<HConstant>(JSRegExpResult::kSize), HType::JSArray(),
NOT_TENURED, JS_ARRAY_TYPE, graph()->GetConstant0());
// Initialize the JSRegExpResult header.
HValue* native_context = Add<HLoadNamedField>(
context(), nullptr,
HObjectAccess::ForContextSlot(Context::NATIVE_CONTEXT_INDEX));
Add<HStoreNamedField>(
result, HObjectAccess::ForMap(),
Add<HLoadNamedField>(
native_context, nullptr,
HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX)));
HConstant* empty_fixed_array =
Add<HConstant>(isolate()->factory()->empty_fixed_array());
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset),
empty_fixed_array);
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset),
empty_fixed_array);
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSArray::kLengthOffset), length);
// Initialize the additional fields.
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kIndexOffset),
index);
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kInputOffset),
input);
// Allocate and initialize the elements header.
HAllocate* elements = BuildAllocateElements(elements_kind, size);
BuildInitializeElementsHeader(elements, elements_kind, length);
Add<HStoreNamedField>(
result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset),
elements);
// Initialize the elements contents with undefined.
BuildFillElementsWithValue(
elements, elements_kind, graph()->GetConstant0(), length,
graph()->GetConstantUndefined());
return result;
}
HValue* HGraphBuilder::BuildNumberToString(HValue* object, AstType* type) {
NoObservableSideEffectsScope scope(this);
......@@ -12168,40 +12107,6 @@ void HOptimizedGraphBuilder::GenerateRegExpExec(CallRuntime* call) {
}
void HOptimizedGraphBuilder::GenerateRegExpFlags(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitExpressions(call->arguments()));
HValue* regexp = Pop();
HInstruction* result =
New<HLoadNamedField>(regexp, nullptr, HObjectAccess::ForJSRegExpFlags());
return ast_context()->ReturnInstruction(result, call->id());
}
void HOptimizedGraphBuilder::GenerateRegExpSource(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitExpressions(call->arguments()));
HValue* regexp = Pop();
HInstruction* result =
New<HLoadNamedField>(regexp, nullptr, HObjectAccess::ForJSRegExpSource());
return ast_context()->ReturnInstruction(result, call->id());
}
// Construct a RegExp exec result with two in-object properties.
void HOptimizedGraphBuilder::GenerateRegExpConstructResult(CallRuntime* call) {
DCHECK_EQ(3, call->arguments()->length());
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
CHECK_ALIVE(VisitForValue(call->arguments()->at(2)));
HValue* input = Pop();
HValue* index = Pop();
HValue* length = Pop();
HValue* result = BuildRegExpConstructResult(length, index, input);
return ast_context()->ReturnValue(result);
}
// Fast support for number to string.
void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
......
......@@ -1417,10 +1417,6 @@ class HGraphBuilder {
// ES6 section 7.4.7 CreateIterResultObject ( value, done )
HValue* BuildCreateIterResultObject(HValue* value, HValue* done);
HValue* BuildRegExpConstructResult(HValue* length,
HValue* index,
HValue* input);
// Allocates a new object according with the given allocation properties.
HAllocate* BuildAllocate(HValue* object_size,
HType type,
......@@ -2202,9 +2198,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder,
F(StringCharCodeAt) \
F(SubString) \
F(RegExpExec) \
F(RegExpConstructResult) \
F(RegExpFlags) \
F(RegExpSource) \
F(NumberToString) \
F(DebugIsActive) \
/* Typed Arrays */ \
......
......@@ -652,10 +652,6 @@ void FullCodeGenerator::EmitToObject(CallRuntime* expr) {
}
void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
EmitIntrinsicAsStubCall(expr, CodeFactory::RegExpConstructResult(isolate()));
}
void FullCodeGenerator::EmitHasProperty() {
Callable callable = CodeFactory::HasProperty(isolate());
PopOperand(callable.descriptor().GetRegisterParameter(1));
......
......@@ -484,7 +484,6 @@ class FullCodeGenerator final : public AstVisitor<FullCodeGenerator> {
F(StringCharCodeAt) \
F(SubString) \
F(RegExpExec) \
F(RegExpConstructResult) \
F(ToInteger) \
F(NumberToString) \
F(ToString) \
......
......@@ -204,13 +204,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ecx, ebx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax, ebx};
......
......@@ -49,7 +49,6 @@ class PlatformInterfaceDescriptor;
V(ConstructStub) \
V(ConstructTrampoline) \
V(RegExpExec) \
V(RegExpConstructResult) \
V(CopyFastSmiOrObjectElements) \
V(TransitionElementsKind) \
V(AllocateHeapNumber) \
......@@ -571,12 +570,6 @@ class RegExpExecDescriptor : public CallInterfaceDescriptor {
CallInterfaceDescriptor)
};
class RegExpConstructResultDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kLength, kIndex, kInput)
DECLARE_DESCRIPTOR(RegExpConstructResultDescriptor, CallInterfaceDescriptor)
};
class CopyFastSmiOrObjectElementsDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kObject)
......
......@@ -249,12 +249,6 @@ Node* IntrinsicsHelper::NumberToString(Node* input, Node* arg_count,
CodeFactory::NumberToString(isolate()));
}
Node* IntrinsicsHelper::RegExpConstructResult(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(input, context,
CodeFactory::RegExpConstructResult(isolate()));
}
Node* IntrinsicsHelper::RegExpExec(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(input, context,
......
......@@ -35,7 +35,6 @@ namespace interpreter {
V(IsTypedArray, is_typed_array, 1) \
V(NewObject, new_object, 2) \
V(NumberToString, number_to_string, 1) \
V(RegExpConstructResult, reg_exp_construct_result, 3) \
V(RegExpExec, reg_exp_exec, 4) \
V(SubString, sub_string, 3) \
V(ToString, to_string, 1) \
......
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
'use strict';
%CheckIsBootstrapping();
// -------------------------------------------------------------------
// ES#sec-getsubstitution
// GetSubstitution(matched, str, position, captures, replacement)
// Expand the $-expressions in the string and return a new string with
// the result.
function GetSubstitution(matched, string, position, captures, replacement) {
var matchLength = matched.length;
var stringLength = string.length;
var capturesLength = captures.length;
var tailPos = position + matchLength;
var result = "";
var pos, expansion, peek, next, scaledIndex, advance, newScaledIndex;
var next = %StringIndexOf(replacement, '$', 0);
if (next < 0) {
result += replacement;
return result;
}
if (next > 0) result += %_SubString(replacement, 0, next);
while (true) {
expansion = '$';
pos = next + 1;
if (pos < replacement.length) {
peek = %_StringCharCodeAt(replacement, pos);
if (peek == 36) { // $$
++pos;
result += '$';
} else if (peek == 38) { // $& - match
++pos;
result += matched;
} else if (peek == 96) { // $` - prefix
++pos;
result += %_SubString(string, 0, position);
} else if (peek == 39) { // $' - suffix
++pos;
result += %_SubString(string, tailPos, stringLength);
} else if (peek >= 48 && peek <= 57) {
// Valid indices are $1 .. $9, $01 .. $09 and $10 .. $99
scaledIndex = (peek - 48);
advance = 1;
if (pos + 1 < replacement.length) {
next = %_StringCharCodeAt(replacement, pos + 1);
if (next >= 48 && next <= 57) {
newScaledIndex = scaledIndex * 10 + ((next - 48));
if (newScaledIndex < capturesLength) {
scaledIndex = newScaledIndex;
advance = 2;
}
}
}
if (scaledIndex != 0 && scaledIndex < capturesLength) {
var capture = captures.at(scaledIndex);
if (!IS_UNDEFINED(capture)) result += capture;
pos += advance;
} else {
result += '$';
}
} else {
result += '$';
}
} else {
result += '$';
}
// Go the the next $ in the replacement.
next = %StringIndexOf(replacement, '$', pos);
// Return if there are no more $ characters in the replacement. If we
// haven't reached the end, we need to append the suffix.
if (next < 0) {
if (pos < replacement.length) {
result += %_SubString(replacement, pos, replacement.length);
}
return result;
}
// Append substring between the previous and the next $ character.
if (next > pos) {
result += %_SubString(replacement, pos, next);
}
}
return result;
}
// -------------------------------------------------------------------
// Exports
utils.Export(function(to) {
to.GetSubstitution = GetSubstitution;
});
})
......@@ -10,7 +10,6 @@
// Imports
var ArrayJoin;
var GetSubstitution;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var MaxSimple;
......@@ -22,7 +21,6 @@ var splitSymbol = utils.ImportNow("split_symbol");
utils.Import(function(from) {
ArrayJoin = from.ArrayJoin;
GetSubstitution = from.GetSubstitution;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
});
......@@ -60,6 +58,90 @@ function StringMatchJS(pattern) {
return regexp[matchSymbol](subject);
}
// ES#sec-getsubstitution
// GetSubstitution(matched, str, position, captures, replacement)
// Expand the $-expressions in the string and return a new string with
// the result.
function GetSubstitution(matched, string, position, captures, replacement) {
var matchLength = matched.length;
var stringLength = string.length;
var capturesLength = captures.length;
var tailPos = position + matchLength;
var result = "";
var pos, expansion, peek, next, scaledIndex, advance, newScaledIndex;
var next = %StringIndexOf(replacement, '$', 0);
if (next < 0) {
result += replacement;
return result;
}
if (next > 0) result += %_SubString(replacement, 0, next);
while (true) {
expansion = '$';
pos = next + 1;
if (pos < replacement.length) {
peek = %_StringCharCodeAt(replacement, pos);
if (peek == 36) { // $$
++pos;
result += '$';
} else if (peek == 38) { // $& - match
++pos;
result += matched;
} else if (peek == 96) { // $` - prefix
++pos;
result += %_SubString(string, 0, position);
} else if (peek == 39) { // $' - suffix
++pos;
result += %_SubString(string, tailPos, stringLength);
} else if (peek >= 48 && peek <= 57) {
// Valid indices are $1 .. $9, $01 .. $09 and $10 .. $99
scaledIndex = (peek - 48);
advance = 1;
if (pos + 1 < replacement.length) {
next = %_StringCharCodeAt(replacement, pos + 1);
if (next >= 48 && next <= 57) {
newScaledIndex = scaledIndex * 10 + ((next - 48));
if (newScaledIndex < capturesLength) {
scaledIndex = newScaledIndex;
advance = 2;
}
}
}
if (scaledIndex != 0 && scaledIndex < capturesLength) {
var capture = captures.at(scaledIndex);
if (!IS_UNDEFINED(capture)) result += capture;
pos += advance;
} else {
result += '$';
}
} else {
result += '$';
}
} else {
result += '$';
}
// Go the the next $ in the replacement.
next = %StringIndexOf(replacement, '$', pos);
// Return if there are no more $ characters in the replacement. If we
// haven't reached the end, we need to append the suffix.
if (next < 0) {
if (pos < replacement.length) {
result += %_SubString(replacement, pos, replacement.length);
}
return result;
}
// Append substring between the previous and the next $ character.
if (next > pos) {
result += %_SubString(replacement, pos, next);
}
}
return result;
}
// ES6, section 21.1.3.14
function StringReplace(search, replace) {
......
......@@ -205,13 +205,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0, a1};
......
......@@ -205,13 +205,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0, a1};
......
......@@ -202,13 +202,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r5, r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r4};
......
......@@ -820,55 +820,6 @@ RUNTIME_FUNCTION(Runtime_RegExpExec) {
isolate, RegExpImpl::Exec(regexp, subject, index, last_match_info));
}
RUNTIME_FUNCTION(Runtime_RegExpFlags) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
return regexp->flags();
}
RUNTIME_FUNCTION(Runtime_RegExpSource) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
return regexp->source();
}
// TODO(jgruber): Remove this once all uses in regexp.js have been removed.
RUNTIME_FUNCTION(Runtime_RegExpConstructResult) {
HandleScope handle_scope(isolate);
DCHECK(args.length() == 3);
CONVERT_SMI_ARG_CHECKED(size, 0);
CHECK(size >= 0 && size <= FixedArray::kMaxLength);
CONVERT_ARG_HANDLE_CHECKED(Object, index, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, input, 2);
Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size);
Handle<Map> regexp_map(isolate->native_context()->regexp_result_map());
Handle<JSObject> object =
isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED);
Handle<JSArray> array = Handle<JSArray>::cast(object);
array->set_elements(*elements);
array->set_length(Smi::FromInt(size));
// Write in-object properties after the length of the array.
array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index);
array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input);
return *array;
}
RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
RETURN_FAILURE_ON_EXCEPTION(isolate,
JSRegExp::Initialize(regexp, source, flags));
return *regexp;
}
RUNTIME_FUNCTION(Runtime_RegExpInternalReplace) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
......
......@@ -458,16 +458,12 @@ namespace internal {
#define FOR_EACH_INTRINSIC_REGEXP(F) \
F(IsRegExp, 1, 1) \
F(RegExpConstructResult, 3, 1) \
F(RegExpCreate, 1, 1) \
F(RegExpExec, 4, 1) \
F(RegExpExecMultiple, 4, 1) \
F(RegExpExecReThrow, 4, 1) \
F(RegExpFlags, 1, 1) \
F(RegExpInitializeAndCompile, 3, 1) \
F(RegExpInternalReplace, 3, 1) \
F(RegExpReplace, 3, 1) \
F(RegExpSource, 1, 1) \
F(StringReplaceGlobalRegExpWithString, 4, 1) \
F(StringReplaceNonGlobalRegExpWithFunction, 3, 1) \
F(StringSplit, 3, 1)
......
......@@ -184,12 +184,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4, r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2, r3};
......
......@@ -2223,7 +2223,6 @@
'js/symbol.js',
'js/array.js',
'js/string.js',
'js/regexp.js',
'js/arraybuffer.js',
'js/typedarray.js',
'js/collection.js',
......
......@@ -202,13 +202,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rcx, rbx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rax, rbx};
......
......@@ -202,13 +202,6 @@ void ConstructTrampolineDescriptor::InitializePlatformSpecific(
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ecx, ebx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax, ebx};
......
......@@ -920,7 +920,6 @@ function TestMapSetSubclassing(container, is_map) {
assertEquals(["match", "tostring"], log);
// TODO(littledan): Is the RegExp constructor correct to create
// the internal slots and do these type checks this way?
assertEquals("biep", %_RegExpSource(o));
assertThrows(() => Object.getOwnPropertyDescriptor(RegExp.prototype,
'source').get(o),
TypeError);
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
function f() {
%_RegExpConstructResult(0, {}, {});
}
f();
f();
%OptimizeFunctionOnNextCall(f);
f();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment