Advertisement
Guest User

Untitled

a guest
Feb 19th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) {
  2. HandleScope scope(isolate);
  3. DisallowHeapAllocation no_allocation;
  4. ASSERT(args.length() == 5);
  5. CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
  6. CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
  7. // If source is the empty string we set it to "(?:)" instead as
  8. // suggested by ECMA-262, 5th, section 15.10.4.1.
  9. if (source->length() == 0) source = isolate->factory()->query_colon_string();
  10.  
  11. CONVERT_ARG_HANDLE_CHECKED(Object, global, 2);
  12. if (!global->IsTrue()) global = isolate->factory()->false_value();
  13.  
  14. CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3);
  15. if (!ignoreCase->IsTrue()) ignoreCase = isolate->factory()->false_value();
  16.  
  17. CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4);
  18. if (!multiline->IsTrue()) multiline = isolate->factory()->false_value();
  19.  
  20. Map* map = regexp->map();
  21. Object* constructor = map->constructor();
  22. if (constructor->IsJSFunction() &&
  23. JSFunction::cast(constructor)->initial_map() == map) {
  24. // If we still have the original map, set in-object properties directly.
  25. regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source);
  26. // Both true and false are immovable immortal objects so no need for write
  27. // barrier.
  28. regexp->InObjectPropertyAtPut(
  29. JSRegExp::kGlobalFieldIndex, *global, SKIP_WRITE_BARRIER);
  30. regexp->InObjectPropertyAtPut(
  31. JSRegExp::kIgnoreCaseFieldIndex, *ignoreCase, SKIP_WRITE_BARRIER);
  32. regexp->InObjectPropertyAtPut(
  33. JSRegExp::kMultilineFieldIndex, *multiline, SKIP_WRITE_BARRIER);
  34. regexp->InObjectPropertyAtPut(
  35. JSRegExp::kLastIndexFieldIndex, Smi::FromInt(0), SKIP_WRITE_BARRIER);
  36. return *regexp;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement