Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1876)

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 2104093003: DBC: Implement OneByteStringFromCharCode and StringToCharCode. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_dbc.cc
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
index 4789edc6d93c188285f405d3c6787099dd1c698b..5a26b539dea296333fab5916469abdfedf47d68b 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -28,6 +28,7 @@
#include "vm/object_store.h"
#include "vm/os_thread.h"
#include "vm/stack_frame.h"
+#include "vm/symbols.h"
namespace dart {
@@ -1525,6 +1526,28 @@ RawObject* Simulator::Call(const Code& code,
}
{
+ BYTECODE(OneByteStringFromCharCode, A_X);
+ const intptr_t char_code = Smi::Value(RAW_CAST(Smi, FP[rD]));
+ ASSERT(char_code >= 0);
+ ASSERT(char_code <= 255);
+ RawString** strings = Symbols::PredefinedAddress();
+ const intptr_t index = char_code + Symbols::kNullCharCodeSymbolOffset;
+ FP[rA] = strings[index];
+ DISPATCH();
+ }
+
+ {
+ BYTECODE(StringToCharCode, A_X);
+ RawOneByteString* str = RAW_CAST(OneByteString, FP[rD]);
+ if (str->ptr()->length_ == Smi::New(1)) {
+ FP[rA] = Smi::New(str->ptr()->data()[0]);
+ } else {
+ FP[rA] = Smi::New(-1);
+ }
+ DISPATCH();
+ }
+
+ {
BYTECODE(AddTOS, A_B_C);
SMI_FASTPATH_TOS(intptr_t, SignedAddWithOverflow);
DISPATCH();
« no previous file with comments | « runtime/vm/intermediate_language_dbc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698