Changeset 197408 in webkit for trunk/Source/JavaScriptCore/runtime
- Timestamp:
- Mar 1, 2016, 1:18:42 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore/runtime
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/Intrinsic.h
r194087 r197408 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 53 53 RegExpTestIntrinsic, 54 54 StringPrototypeValueOfIntrinsic, 55 StringPrototypeReplaceIntrinsic, 55 56 IMulIntrinsic, 56 57 RandomIntrinsic, -
trunk/Source/JavaScriptCore/runtime/JSType.h
r197136 r197408 1 1 /* 2 * Copyright (C) 2006 , 2007, 2008, 2009, 2010, 2011, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2006-2011, 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 78 78 GlobalObjectType, 79 79 ClosureObjectType, 80 80 RegExpObjectType, 81 81 ProxyObjectType, 82 82 -
trunk/Source/JavaScriptCore/runtime/RegExpObject.h
r182747 r197408 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 * Copyright (C) 2003, 2007, 2008, 2012 Apple Inc. All Rights Reserved.3 * Copyright (C) 2003, 2007, 2008, 2012, 2016 Apple Inc. All Rights Reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 72 72 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) 73 73 { 74 return Structure::create(vm, globalObject, prototype, TypeInfo( ObjectType, StructureFlags), info());74 return Structure::create(vm, globalObject, prototype, TypeInfo(RegExpObjectType, StructureFlags), info()); 75 75 } 76 76 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r197261 r197408 136 136 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("match", stringProtoFuncMatch, DontEnum, 1); 137 137 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("repeat", stringProtoFuncRepeat, DontEnum, 1); 138 JSC_NATIVE_ FUNCTION_WITHOUT_TRANSITION("replace", stringProtoFuncReplace, DontEnum, 2);138 JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION("replace", stringProtoFuncReplace, DontEnum, 2, StringPrototypeReplaceIntrinsic); 139 139 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("slice", stringProtoFuncSlice, DontEnum, 2); 140 140 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("split", stringProtoFuncSplit, DontEnum, 2); … … 485 485 } 486 486 487 static NEVER_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSString* string, JSValue searchValue) 488 { 489 JSValue replaceValue = exec->argument(1); 490 String replacementString; 491 CallData callData; 492 CallType callType = getCallData(replaceValue, callData); 493 if (callType == CallTypeNone) { 494 replacementString = replaceValue.toString(exec)->value(exec); 495 if (exec->hadException()) 496 return JSValue::encode(jsUndefined()); 497 } 498 487 static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch( 488 ExecState* exec, JSString* string, JSValue searchValue, CallData& callData, CallType callType, 489 String& replacementString, JSValue replaceValue) 490 { 499 491 const String& source = string->value(exec); 500 492 unsigned sourceLen = source.length(); … … 673 665 } 674 666 675 static inline EncodedJSValue replaceUsingStringSearch(ExecState* exec, JSString* jsString, JSValue searchValue) 667 EncodedJSValue JIT_OPERATION operationStringProtoFuncReplaceRegExpString( 668 ExecState* exec, JSString* thisValue, RegExpObject* searchValue, JSString* replaceString) 669 { 670 CallData callData; 671 String replacementString = replaceString->value(exec); 672 return replaceUsingRegExpSearch( 673 exec, thisValue, searchValue, callData, CallTypeNone, replacementString, replaceString); 674 } 675 676 static ALWAYS_INLINE EncodedJSValue replaceUsingRegExpSearch(ExecState* exec, JSString* string, JSValue searchValue, JSValue replaceValue) 677 { 678 String replacementString; 679 CallData callData; 680 CallType callType = getCallData(replaceValue, callData); 681 if (callType == CallTypeNone) { 682 replacementString = replaceValue.toString(exec)->value(exec); 683 if (exec->hadException()) 684 return JSValue::encode(jsUndefined()); 685 } 686 687 return replaceUsingRegExpSearch( 688 exec, string, searchValue, callData, callType, replacementString, replaceValue); 689 } 690 691 static ALWAYS_INLINE EncodedJSValue replaceUsingStringSearch(ExecState* exec, JSString* jsString, JSValue searchValue, JSValue replaceValue) 676 692 { 677 693 const String& string = jsString->value(exec); … … 685 701 return JSValue::encode(jsString); 686 702 687 JSValue replaceValue = exec->argument(1);688 703 CallData callData; 689 704 CallType callType = getCallData(replaceValue, callData); … … 788 803 } 789 804 805 ALWAYS_INLINE EncodedJSValue replace( 806 ExecState* exec, JSString* string, JSValue searchValue, JSValue replaceValue) 807 { 808 if (searchValue.inherits(RegExpObject::info())) 809 return replaceUsingRegExpSearch(exec, string, searchValue, replaceValue); 810 return replaceUsingStringSearch(exec, string, searchValue, replaceValue); 811 } 812 813 ALWAYS_INLINE EncodedJSValue replace( 814 ExecState* exec, JSValue thisValue, JSValue searchValue, JSValue replaceValue) 815 { 816 if (!checkObjectCoercible(thisValue)) 817 return throwVMTypeError(exec); 818 JSString* string = thisValue.toString(exec); 819 if (exec->hadException()) 820 return JSValue::encode(jsUndefined()); 821 return replace(exec, string, searchValue, replaceValue); 822 } 823 790 824 EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec) 791 825 { 792 JSValue thisValue = exec->thisValue(); 793 if (!checkObjectCoercible(thisValue)) 794 return throwVMTypeError(exec); 795 JSString* string = thisValue.toString(exec); 796 JSValue searchValue = exec->argument(0); 797 798 if (searchValue.inherits(RegExpObject::info())) 799 return replaceUsingRegExpSearch(exec, string, searchValue); 800 return replaceUsingStringSearch(exec, string, searchValue); 826 return replace(exec, exec->thisValue(), exec->argument(0), exec->argument(1)); 827 } 828 829 EncodedJSValue JIT_OPERATION operationStringProtoFuncReplaceGeneric( 830 ExecState* exec, EncodedJSValue thisValue, EncodedJSValue searchValue, 831 EncodedJSValue replaceValue) 832 { 833 return replace( 834 exec, JSValue::decode(thisValue), JSValue::decode(searchValue), 835 JSValue::decode(replaceValue)); 801 836 } 802 837 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.h
r196498 r197408 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.3 * Copyright (C) 2007, 2008, 2013, 2016 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 22 22 #define StringPrototype_h 23 23 24 #include "JITOperations.h" 24 25 #include "StringObject.h" 25 26 … … 27 28 28 29 class ObjectPrototype; 30 class RegExpObject; 29 31 30 32 class StringPrototype : public StringObject { … … 52 54 }; 53 55 56 EncodedJSValue JIT_OPERATION operationStringProtoFuncReplaceGeneric( 57 ExecState* exec, EncodedJSValue thisValue, EncodedJSValue searchValue, 58 EncodedJSValue replaceValue); 59 60 EncodedJSValue JIT_OPERATION operationStringProtoFuncReplaceRegExpString( 61 ExecState* exec, JSString* thisValue, RegExpObject* searchValue, JSString* replaceValue); 62 54 63 } // namespace JSC 55 64
Note:
See TracChangeset
for help on using the changeset viewer.