1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// File: StringNative.cpp
//
//
// Purpose: The implementation of the String class.
//
//
#include "common.h"
#include "object.h"
#include "utilcode.h"
#include "excep.h"
#include "frames.h"
#include "field.h"
#include "vars.hpp"
#include "stringnative.h"
#include "comutilnative.h"
#include "metasig.h"
#include "excep.h"
// Compile the string functionality with these pragma flags (equivalent of the command line /Ox flag)
// Compiling this functionality differently gives us significant throughout gain in some cases.
#if defined(_MSC_VER) && defined(TARGET_X86)
#pragma optimize("tgy", on)
#endif
/*==================================GETCHARAT===================================
**Returns the character at position index. Thows IndexOutOfRangeException as
**appropriate.
**This method is not actually used. JIT will generate code for indexer method on string class.
**
==============================================================================*/
FCIMPL2(FC_CHAR_RET, COMString::GetCharAt, StringObject* str, INT32 index) {
FCALL_CONTRACT;
FC_GC_POLL_NOT_NEEDED();
VALIDATEOBJECT(str);
if (str == NULL) {
FCThrow(kNullReferenceException);
}
_ASSERTE(str->GetMethodTable() == g_pStringClass);
if (index >=0 && index < (INT32)str->GetStringLength()) {
//Return the appropriate character.
return str->GetBuffer()[index];
}
FCThrow(kIndexOutOfRangeException);
}
FCIMPLEND
/*==================================LENGTH=================================== */
FCIMPL1(INT32, COMString::Length, StringObject* str) {
FCALL_CONTRACT;
FC_GC_POLL_NOT_NEEDED();
if (str == NULL)
FCThrow(kNullReferenceException);
FCUnique(0x11);
return str->GetStringLength();
}
FCIMPLEND
FCIMPL2(FC_BOOL_RET, COMString::FCTryGetTrailByte, StringObject* thisRefUNSAFE, UINT8 *pbData)
{
FCALL_CONTRACT;
STRINGREF thisRef = ObjectToSTRINGREF(thisRefUNSAFE);
FC_RETURN_BOOL(thisRef->GetTrailByte(pbData));
}
FCIMPLEND
FCIMPL2(VOID, COMString::FCSetTrailByte, StringObject* thisRefUNSAFE, UINT8 bData)
{
FCALL_CONTRACT;
STRINGREF thisRef = ObjectToSTRINGREF(thisRefUNSAFE);
HELPER_METHOD_FRAME_BEGIN_1(thisRef);
thisRef->SetTrailByte(bData);
HELPER_METHOD_FRAME_END();
}
FCIMPLEND
// Revert to command line compilation flags
#if defined(_MSC_VER) && defined(TARGET_X86)
#pragma optimize ("", on)
#endif
|