JSCBridgeToll.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (C) 2013 Sony Computer Entertainment Inc.
  2. // All Rights Reserved.
  3. #include "config.h"
  4. #include "JSCBridgeToll.h"
  5. #if ENABLE(DETACHED_JIT)
  6. #include "CodeBlock.h"
  7. #include "JSCJSValueInlines.h"
  8. #include "Opcode.h"
  9. #include "VM.h"
  10. #include <assert.h>
  11. namespace JSC {
  12. JSCBridgeToll::JSCBridgeToll(JSCBridge::Payload * payload)
  13. : m_payload(payload)
  14. {
  15. m_payload->m_toll = this;
  16. }
  17. JSCBridgeToll::~JSCBridgeToll()
  18. {
  19. // 'refund' the toll...
  20. m_payload->m_toll = NULL;
  21. }
  22. JSCBridgeToll::CodeBlockToll const & JSCBridgeToll::forCodeBlock(CodeBlock const * codeBlock)
  23. {
  24. return m_codeBlockTollMap.find(codeBlock)->value;
  25. }
  26. JSCBridgeToll::GlobalObjectToll const & JSCBridgeToll::forGlobalObject(JSGlobalObject const * globalObject)
  27. {
  28. return m_globalObjectTollMap.find(globalObject)->value;
  29. }
  30. void JSCBridgeToll::prepare(VM * vm)
  31. {
  32. this->m_vm.m_stringStructure = vm->stringStructure.get();
  33. }
  34. #if !BUILDING_DETACHED_JIT
  35. void JSCBridgeToll::prepare(CodeBlock * codeBlock)
  36. {
  37. CodeBlockTollMap::AddResult entry(m_codeBlockTollMap.add(codeBlock, CodeBlockToll()));
  38. UnlinkedCodeBlock const * const unlinkedCodeblock(codeBlock->unlinkedCodeBlock());
  39. if (entry.isNewEntry) {
  40. CodeBlockToll & toll(entry.iterator->value);
  41. toll.m_codeType = codeBlock->codeType();
  42. toll.m_jumpTargets = unlinkedCodeblock->m_jumpTargets.data();
  43. toll.m_numberOfJumpTargets = unlinkedCodeblock->m_jumpTargets.size();
  44. toll.m_dfgCapabilityLevel = codeBlock->canCompileWithDFG();
  45. }
  46. JSGlobalObject * globalObject(codeBlock->globalObject());
  47. if (globalObject) {
  48. prepare(globalObject);
  49. }
  50. }
  51. void JSCBridgeToll::prepare(JSGlobalObject * globalObject)
  52. {
  53. GlobalObjectTollMap::AddResult entry(m_globalObjectTollMap.add(globalObject, GlobalObjectToll()));
  54. if (entry.isNewEntry) {
  55. GlobalObjectToll & toll(entry.iterator->value);
  56. memcpy(&(toll.m_specialPointers[0]), &(globalObject->m_specialPointers[0]), sizeof(void *) * Special::TableSize);
  57. }
  58. }
  59. #endif // #if BUILDING_DETACHED_JIT
  60. } // namespace JSC
  61. #endif // #if ENABLE(DETACHED_JIT)