Revision: 20559
Author: [email protected]
Date: Tue Apr 8 06:45:53 2014 UTC
Log: Handlify LookupSingleCharacterStringFromCode.
[email protected]
Review URL: https://codereview.chromium.org/227593004
http://code.google.com/p/v8/source/detail?r=20559
Modified:
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/handles.cc
/branches/bleeding_edge/src/handles.h
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/json-parser.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/factory.cc Tue Apr 8 06:15:20 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Tue Apr 8 06:45:53 2014 UTC
@@ -285,6 +285,14 @@
isolate()->heap()->AllocateRawTwoByteString(length, pretenure),
SeqTwoByteString);
}
+
+
+Handle<String> Factory::LookupSingleCharacterStringFromCode(uint32_t
index) {
+ CALL_HEAP_FUNCTION(
+ isolate(),
+ isolate()->heap()->LookupSingleCharacterStringFromCode(index),
+ String);
+}
// Returns true for a character in a range. Both limits are inclusive.
@@ -469,7 +477,7 @@
int length = end - begin;
if (length <= 0) return empty_string();
if (length == 1) {
- return LookupSingleCharacterStringFromCode(isolate(), str->Get(begin));
+ return LookupSingleCharacterStringFromCode(str->Get(begin));
}
if (length == 2) {
// Optimization for 2-byte strings often used as keys in a
decompression
=======================================
--- /branches/bleeding_edge/src/factory.h Tue Apr 8 06:15:20 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Tue Apr 8 06:45:53 2014 UTC
@@ -142,6 +142,8 @@
int length,
PretenureFlag pretenure = NOT_TENURED);
+ Handle<String> LookupSingleCharacterStringFromCode(uint32_t index);
+
// Create a new cons string object which consists of a pair of strings.
MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
Handle<String> right);
=======================================
--- /branches/bleeding_edge/src/handles.cc Fri Apr 4 13:05:37 2014 UTC
+++ /branches/bleeding_edge/src/handles.cc Tue Apr 8 06:45:53 2014 UTC
@@ -177,15 +177,6 @@
ASSERT(!str.is_null());
return Object::GetPropertyOrElement(obj, str);
}
-
-
-Handle<String> LookupSingleCharacterStringFromCode(Isolate* isolate,
- uint32_t index) {
- CALL_HEAP_FUNCTION(
- isolate,
- isolate->heap()->LookupSingleCharacterStringFromCode(index),
- String);
-}
// Wrappers for scripts are kept alive and cached in weak global
=======================================
--- /branches/bleeding_edge/src/handles.h Fri Apr 4 13:05:37 2014 UTC
+++ /branches/bleeding_edge/src/handles.h Tue Apr 8 06:45:53 2014 UTC
@@ -302,9 +302,6 @@
Handle<Object> GetProperty(Handle<JSReceiver> obj, const char* name);
-Handle<String> LookupSingleCharacterStringFromCode(Isolate* isolate,
- uint32_t index);
-
// Get the JS object corresponding to the given script; create it
// if none exists.
Handle<JSValue> GetScriptWrapper(Handle<Script> script);
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu Apr 3
10:39:04 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Apr 8
06:45:53 2014 UTC
@@ -4097,7 +4097,7 @@
if (std::isfinite(c_code->DoubleValue())) {
uint32_t code = c_code->NumberValueAsInteger32() & 0xffff;
return HConstant::New(zone, context,
- LookupSingleCharacterStringFromCode(isolate, code));
+ isolate->factory()->LookupSingleCharacterStringFromCode(code));
}
return HConstant::New(zone, context,
isolate->factory()->empty_string());
}
=======================================
--- /branches/bleeding_edge/src/json-parser.h Fri Apr 4 12:06:11 2014 UTC
+++ /branches/bleeding_edge/src/json-parser.h Tue Apr 8 06:45:53 2014 UTC
@@ -257,8 +257,7 @@
break;
default:
message = "unexpected_token";
- Handle<Object> name =
- LookupSingleCharacterStringFromCode(isolate_, c0_);
+ Handle<Object> name =
factory->LookupSingleCharacterStringFromCode(c0_);
Handle<FixedArray> element = factory->NewFixedArray(1);
element->set(0, *name);
array = factory->NewJSArrayWithElements(element);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Apr 8 06:38:19 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Tue Apr 8 06:45:53 2014 UTC
@@ -3235,16 +3235,6 @@
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
JSObject::Freeze(object));
return *result;
}
-
-
-MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
- Object* char_code) {
- if (char_code->IsNumber()) {
- return isolate->heap()->LookupSingleCharacterStringFromCode(
- NumberToUint32(char_code) & 0xffff);
- }
- return isolate->heap()->empty_string();
-}
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCharCodeAt) {
@@ -3272,9 +3262,13 @@
RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) {
- SealHandleScope shs(isolate);
+ HandleScope handlescope(isolate);
ASSERT(args.length() == 1);
- return CharFromCode(isolate, args[0]);
+ if (args[0]->IsNumber()) {
+ uint32_t code = NumberToUint32(args[0]) & 0xffff;
+ return *isolate->factory()->LookupSingleCharacterStringFromCode(code);
+ }
+ return isolate->heap()->empty_string();
}
@@ -4883,8 +4877,7 @@
static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
if (index < static_cast<uint32_t>(string->length())) {
string->TryFlatten();
- return LookupSingleCharacterStringFromCode(
- string->GetIsolate(),
+ return
string->GetIsolate()->factory()->LookupSingleCharacterStringFromCode(
string->Get(index));
}
return Execution::CharAt(string, index);
@@ -6854,7 +6847,7 @@
}
for (int i = position; i < length; ++i) {
Handle<Object> str =
- LookupSingleCharacterStringFromCode(isolate, s->Get(i));
+ isolate->factory()->LookupSingleCharacterStringFromCode(s->Get(i));
elements->set(i, *str);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.