Skip to content

Instantly share code, notes, and snippets.

@dherman
Last active June 16, 2018 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dherman/3f3c36c88de231e918bc51c4fa116453 to your computer and use it in GitHub Desktop.
Save dherman/3f3c36c88de231e918bc51c4fa116453 to your computer and use it in GitHub Desktop.
SOLVED: I missed a conditional

Why doesn't this throw an exception?

SOLVED: It checks the length and returns without throwing in NEW_STRING

  } else if (length > i::String::kMaxLength) {                             \
    result = MaybeLocal<String>();                                         \

ASSERTION: DCHECK((isolate)->has_pending_exception())

TRACE:

ASSIGN_RETURN_ON_EXCEPTION_VALUE(..)
 DCHECK((isolate)->has_pending_exception()); \
ASSIGN_RETURN_ON_EXCEPTION(..)
  ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, MaybeHandle<T>())
MaybeHandle<String> Factory::NewStringFromUtf8(Vector, PretenureFlag)
  ASSIGN_RETURN_ON_EXCEPTION(
      isolate(), result,
      NewRawTwoByteString(non_ascii_start + utf16_length, pretenure), String);
i::MaybeHandle<i::String> NewString(i::Factory *, v8::NewStringType, i::Vector<const char>)
  return factory->NewStringFromUtf8(string);
NEW_STRING(..)
        NewString(i_isolate->factory(), type,                              \
                  i::Vector<const Char>(data, length))                     \
Local<String> String::NewFromUtf8(Isolate *, const char *, NewStringType, int)
  NEW_STRING(isolate, String, NewFromUtf8, char, data,
             static_cast<v8::NewStringType>(type), length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment